I'm trying to migrate an old Google App Engine (standard environment) project written in Go to runtime 1.12. I haven't touched it since late 2017 and a lot seems to have changed since then. I've been able to sort some things out, but I fail to deploy the code since I have some external dependencies.
Relevant parts of the console output when trying to deploy
d:\src\go\src\data-axe>go env GOPATH
d:\src\go
d:\src\go\src\data-axe>gcloud app deploy --no-promote
...
Error type: BuildError.
Error message: 2019/09/27 19:10:09 Your app is not on your GOPATH, this build may fail.
2019/09/27 19:10:10 Building from Go source in /tmp/staging/srv, with main package at ./...
2019/09/27 19:10:10 Building /tmp/staging/srv, saving to /tmp/staging/usr/local/bin/start
2019/09/27 19:10:11 Wrote build output to /builder/outputs/output
2019/09/27 19:10:11 Failed to build app: Your app is not on your GOPATH, please move it there and try again.
...
err=exit status 1, out=srv/main.go:6:2: cannot find package "github.com/microcosm-cc/bluemonday" in any of:
...
As seen in the snippet above my GOPATH is set to d:\src\go
, my app is in d:\src\go\src\data-axe
and and Bluemonday that I'm using is in d:\src\go\src\github.com\microcosm-cc\bluemonday
so to my best knowledge all of this is in my GOPATH.
The App Engine documentation for specifying dependencies say
If your application is in a directory on your GOPATH, App Engine analyzes, copies, and uploads your imports from GOPATH. This approach supports vendor directories.
There must be something I don't understand here. I have both my code and the library I use in my GOPATH but the App Engine doesn't seem to pick up and upload my import when I try to deploy.
The import in my main.go is using an absolute path as the documentation say it should:
package main
import (
"fmt"
"net/http"
"github.com/microcosm-cc/bluemonday"
"strings"
"log"
"os"
)
What am I doing wrong?
Edit
Full output of go env
:
d:\src\go\src\data-axe>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\niklas\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=d:\src\go
set GOPROXY=
set GORACE=
set GOROOT=c:\go
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\niklas\AppData\Local\Temp\go-build168636674=/tmp/go-build -gno-record-gcc-switches
I managed to solve this problem in two different ways.
The first was to copy my project outside of my $GOPATH and enable go modules like explained in this simple guide. When I did this I was able to successfully deploy my application including all it's dependencies.
I also manged to solve the problem without go modules. It turned out that it was not only my project that hadn't been touched in a very long time. My Google Cloud SDK was also severely outdated. After I updated it with gcloud components update
I was able to deploy my application normally without any problems.