如何为在App Engine上运行的Go App启动Go Development Server

I am trying to run a go API app I run the command.

dev_appserver.py --port=9999 app.yaml

I got the error

ERROR    2018-01-05 06:50:27,346 instance_factory.py:196] Failed to build Go application: (Executed command: /home/bitsbridge/google-cloud-sdk/platform/google_appengine/goroot-1.8/bin/go-app-builder -app_base /home/bitsbridge/go/src/bitbucket.org/bigkittylabs/uout-go/server -api_version go1 -arch 8 -dynamic -goroot /home/bitsbridge/google-cloud-sdk/platform/google_appengine/goroot-1.8 -gopath /home/bitsbridge/go -nobuild_files ^^$ -incremental_rebuild -unsafe -print_extras_hash server.go)

2018/01/05 12:20:27 Can't find package "C" in $GOPATH: cannot find package "C" in any of:
    /home/bitsbridge/google-cloud-sdk/platform/google_appengine/goroot-1.8/src/C (from $GOROOT)
    /home/bitsbridge/go/src/C (from $GOPATH)
2018/01/05 12:20:27 go-app-builder: Failed parsing input: parser: bad import "unsafe" in github.com/mattn/go-sqlite3/doc.go from GOPATH

My go env is

GOARCH="386"
GOBIN="/home/bitsbridge/go/bin"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/bitsbridge/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_386"
GCCGO="gccgo"
GO386="sse2"
CC="gcc"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build008385594=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

help me please. thanx in advance.

The two errors you mention show that it cannot find:

  • package C: this mean something you import is using cgo
  • package unsafe: something you import is using unsafe

The quickstarts spell out fairly clearly that the standard environment does not allow the use of unsafe or cgo. You should use the Flexible environment instead.