At Vercel, we are passionate about making developers from all backgrounds productive. Earlier this week, we announced our Rust Builder, @vercel/rust, and got very positive feedback from the community.
Today, we are once again very excited as we announce support for Go modules on @vercel/go.

The case for Go modules

Modules record precise dependency requirements and create reproducible builds. With Modules, you can be confident that the dependencies used in the production build of your Go project are exactly the same version as the ones you used in development. By preventing the inclusion of an incompatible version, you can maintain the reliability of your Go application.
To showcase the use of Go modules with Vercel, we implemented an Image to ASCII converter in Golang, and deployed it serverless using @vercel/go. The converter can also be run from the command line using CURL.

To run Image to ASCII through the command line, run: curl

Using modules

If you haven't worked with them yet, the Go wiki explains Go Modules well.
To use and deploy Go Modules with Vercel, we start by first creating a module:
$ go mod init module-name

go mod init helps initiate a Go module. It accepts the module name as an argument.

To add packages we are interested in, we use go get package-name and then import them within index.go. In the case of Image to ASCII, the import section is structured as follows:
import (

    ascii ""
    ui ""

The index.go file in Image to ASCII includes multiple external packages. Examples include go-asciibot and goasciiart.

Package names

Previously, we enforced that all @vercel/go packages be named main for @vercel/go to be able to build it. Since the Builder supplies the main function and it isn't explicitly defined on the source Go file, some text editors warned about the missing main.

Using the previously required main as the package name resulted in a warning by text editors.

With the newly introduced support for Go Modules, we no longer require the package to be called main. All package names are supported, and unless the name used is main, text editors will no longer throw the warning.
package ascii

import (

func Handler(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintf(w, "<h1>Custom: Hello from Go on Vercel!</h1>")

In this example, we are calling the package ascii.

Conclusion and further reading

Now that @vercel/go officially supports Go modules, we are very keen to discover the Go applications you build and deploy with it. Please do let us know about the interesting projects you are building, and how we can be of further service. You can reach out with feedback and comments around @vercel/go over Twitter.
The @vercel/go Builder is completely open source. We welcome contributions and encourage you to create your own Builders for your favourite technology - we also have a detailed guide in place to help you.