0

I am unable to build/deploy a digital ocean function that relies on nonstandard libraries (some third party, others local). I have three projects: an API, the DO functions, and a common library used by both. I tried the solution described in this post but it didn't fix the issue.

$ doctl serverless deploy functions

results in

Deploying '/home/swpulitzer/temp/repo/functions/functions'
  to namespace 'fn-51b50945-486a-4071-9820-13e076fd4ee8'
  on host 'https://faas-nyc1-2ef2e6cc.doserverless.co'
Submitted function 'bots/whiteface' for remote building and deployment in runtime go:default (id: 1a040a6618174c38840a6618177c38e5)
Transcript of remote build session for action 'bots/whiteface':
Output of failed build in %s
/tmp/slices/builds/fn-51b50945-486a-4071-9820-13e076fd4ee8/bots_whiteface/2025-11-24T20-24-13.602Z/packages/bots/whiteface
initializing modules
go: creating new go.mod: module exec
go: to add module requirements and sums:
    go mod tidy
building
scrape.go:4:2: package api/common is not in GOROOT (/usr/local/go/src/api/common)
scrape.go:5:2: package api/handlers is not in GOROOT (/usr/local/go/src/api/handlers)
scrape.go:6:2: package api/logger is not in GOROOT (/usr/local/go/src/api/logger)
scrape.go:8:2: package common/models is not in GOROOT (/usr/local/go/src/common/models)
scrape.go:11:2: package functions/lib is not in GOROOT (/usr/local/go/src/functions/lib)
scrape.go:18:2: no required module provides package github.com/PuerkitoBio/goquery; to add it:
    go get github.com/PuerkitoBio/goquery
scrape.go:19:2: no required module provides package github.com/labstack/gommon/log; to add it:
    go get github.com/labstack/gommon/log


My project structure is below. Is it possible to tell doctl where these packages are so it can link to them in the build?

repo/ <- workspace
  go.work
  go.work.sum
  api/     <-- API module
  common/    <-- common module used by both API and functions
  functions/    <-- Digital Ocean functions
    go.mod
    go.sum
    lib/
      objects.go
      utilities.bo
    functions/
      project.yml
      packages/
        bots/
          whiteface/
            main.go
            scrape.go
3
  • You do it the same regardless of where the package is being built. How to you build and test locally? The output indicates you are missing the go.mod for your module, so it's trying to resolve the dependencies on the fly. Commented Nov 24 at 20:57
  • Thanks, @Mr_Pink. Along the lines of what is recommended here, I did try adding go.mod to the function directory (in this case, whiteface/). But then things get weirder when I attempt to build, and doctl returns bots/whiteface/go.mod:3: invalid go version '1.25.2': must match format 1.23. Huh? It also resports that it "Submitted function 'bots/whiteface' for remote building and deployment" which seems odd because why is it trying to build remotely? Commented Nov 24 at 21:34
  • They are probably using a older go runtime, so you will have to also specify that same older version to work. "Local" dependencies are not a thing in Go, but you can use replace in a main package's module to locate directories by relative paths. It would probably just be better to include the local packages within the module if you don't want to publish them, rather than trying to force them into whatever process this deploy mechanism uses. Commented Nov 24 at 21:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.