How to use go packages with DO Functions?

How can external libraries from Go can be used in the FAAS product? I.e. running the following function:

package main

import ""

func Main(args map[string]interface{}) map[string]interface{} {
	name, ok := args["name"].(string)
	if !ok {
		name = "stranger"
	msg := make(map[string]interface{})
	msg["body"] = "Hello " + name + "!"
	logrus.Fatal("FAAS can't be used with external Go libraries like i.e.")
	return msg

leads to the following error:

stderr: exec__.go:3:8: no required module provides package; to add it:
stderr:  go get
stderr: failed go build -o /tmp/action/1/bin/exec -ldflags -s -w 
stderr: in /tmp/action/1/src 
stderr: env {'GOROOT': '/usr/local/go', 'GOPATH': '/tmp/go', 'GO111MODULE': 'on', 'GOCACHE': '/tmp', 'PATH': '/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
stderr: The action did not initialize or run as expected. Log data might be missing.

After adding a go.mod / go.sum, the same error occured.

Help is really appreciated! Thanks in advance.

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @ocmer

I ran into the same issue as you, I was able to get it to work by moving the go.mod and go.sum files into the same directory as the main.go file.

You can see my function here:

Found the answer here:

Hi there,

I believe that you need to add the --remote-build flag to your doctl serverless deploy command in order for this to work.

Here is a link to a demo project that utilizes Go modules:

The complete command from the example is:

doctl serverless deploy sample-functions-golang-presigned-url --remote-build



This comment has been deleted