AppEngine “appengine” package always fails with “s

2019-09-05 16:59发布

Using the AppEngine 1.9.40 SDK, I can't even import the "appengine" package.

app.yaml:

application: testapp
version: 1
runtime: go
api_version: go1

handlers:
- url: /.*
  script: _go_app

Go code:

package main

import (
    "google.golang.org/appengine"
)

func init() {
    appengine.IsDevAppServer()
}

func main() {
    // This is only here because go-get needs on it.
}

Command-line:

$ GOPATH=$(pwd) goapp serve

Error:

2016/08/01 23:58:02 go-app-builder: Failed parsing input: parser: bad import "unsafe" in src/golang.org/x/net/icmp/helper.go

What can be done to get past this?

1条回答
Root(大扎)
2楼-- · 2019-09-05 17:26

All code in the application directory tree (the root is the directory containing app.yaml) is compiled in to the app. Appengine rejects code that uses "unsafe".

The fix is to move the offending code out of the application directory tree. Here's one possible way to arrange the code:

$GOPATH
    src
        testapp
            app.yaml
            app.go
        golang.org
            x
                net
                    icmp
                    ... and so on

It's also possible that using package main will cause some trouble. If the above does not work, change the package name.

Appengine apps are not go-gettable. Don't struggle to make them so.

There's more discussion on this topic at https://github.com/golang/gddo/issues/428.

查看更多
登录 后发表回答