本文介绍了AppEngine“appengine”包总是以“系统调用”或“不安全”导入失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用AppEngine 1.9.40 SDK,我甚至无法导入appengine包。

app.yaml:

 应用程序:testapp 
版本:1
运行时:go
api_version:go1

处理程序:
- url:/.*
script:_go_app

前往代码:

 包主

导入(
google.golang.org/appengine


func init(){
appengine.IsDevAppServer()
}

func main(){
// This只是在这里,因为得到它的需要。

命令行:

  $ GOPATH = $(pwd)goapp serve 

错误:

  2016/08/01 23:58:02 go-app-builder:解析输入失败:解析器:坏导入src / golang.org / x / net / icmp / helper.go中的unsafe

要完成这项工作吗?

解决方案

应用程序目录树中的所有代码(根目录是包含app.yaml的目录)被编译到应用程序。 Appengine拒绝使用不安全的代码。



解决方法是将违规代码移出应用程序目录树。这里有一种可能的方式来安排代码:

  $ GOPATH 
src
testapp
app .yaml
app.go
golang.org
x
净值
icmp
...等等

使用软件包 main 也会导致一些麻烦。如果以上操作无效,请更改软件包名称。



Appengine应用程序无法使用。不要费力地让它们成为现实。



在。


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?

解决方案

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.

这篇关于AppEngine“appengine”包总是以“系统调用”或“不安全”导入失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 22:03