坏的导入“系统调用”用于云存储API [英] bad import "syscall" for cloud storage APIs

查看:99
本文介绍了坏的导入“系统调用”用于云存储API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 https://cloud.google.com/appengine/docs/go/googlecloudstorageclient/download 中的说明开始从现在开始迁移一些代码已过时,将API迁移到新的Cloud Storage API中,但未获成功。



我遵循的步骤是...



我设置了$ GOPATH,所以我跳过了第1步。



我继续步骤#2:

goapp get -u golang.org / x / oauth2



goapp get -u google.golang.org/cloud/storage

我没有在托管虚拟机上开发,因此我跳过第3步。



现在,当我运行该应用程序,得到:


$ b

go-app-builder:解析输入失败:parser:bad importsyscallin goapp / src /golang.org/x/net/internal/nettest/error_posix.go



我做错了什么?






步骤重现




  • https://console.cloud.google.com/storage/browser/appengine-sdks/featured/ 。按照 https://cloud.google.com/appengine/downloads?hl=zh_CN上记录的安装说明进行操作= zh-CN


  • 创建一个appengine项目目录:

  • %mkdir $ HOME / myapp





    我使用的版本没有静态资源:

     应用程序:myapp 
    版本:alpha-001
    运行时:go
    api_version:go1

    处理程序:
    - url:/.*
    脚本:_go_app




    • 为Go源文件创建位置。


    %mkdir $ HOME / myapp / go




    • 将您的GOPATH设置为您的源位置


    • $ b $ p

      %export GOPATH = $ HOME / myapp / go





      %goapp get github.com/golang/e xample / appengine-hello



      该命令将示例应用程序下载到GOPATH中的第一个路径条目



      %go get -u golang.org/x / oauth2



      %go get -u google.golang.org/cloud/storage


      • 尝试运行您的应用程序



      <你会看到下面的编译错误(没有堆栈跟踪):



      2015/12/23 10:37:07 go-app-builder:解析输入失败:解析器:在go / src / golang中输入syscall .org / x / net / ipv6 / control_unix.go

      解决方案

      在两种情况下:

      <1>通过导入另一个使用它的包隐式导入 syscall ,如这个相关的问题



      2 )将你的软件包源文件放在 GOPATH中位于或低于您项目的app.yaml所在的目录中(例如, 〜/ go 中的 app.yaml ,并在〜/ go / gopath / src 中打包源代码)。如果您的GOPATH中存在像 x / net / internal / nettest 这样的包, syscall 导入将被解析为 goapp 在编译时抛出编译错误。

      避免这两种情况应该足以防止任何 bad importsyscall错误或相关的编译错误。


      I am following the instructions on https://cloud.google.com/appengine/docs/go/googlecloudstorageclient/download to begin migrating some code from the, now deprecated, Files API to the new Cloud Storage API without success.

      The steps I'm following are ...

      I'm running appengine v1.9.23 which is later than the required appengine v1.8.1.

      My $GOPATH is set, so I skip step #1.

      I proceed to step #2:

      goapp get -u golang.org/x/oauth2

      goapp get -u google.golang.org/cloud/storage

      I am not developing on a managed VM, so I skip step #3.

      Now when I run the application, I get:

      go-app-builder: Failed parsing input: parser: bad import "syscall" in goapp/src/golang.org/x/net/internal/nettest/error_posix.go

      What am I doing wrong?


      Steps to reproduce

      % mkdir $HOME/myapp

      I use a version that does not have the static resources:

      application: myapp
      version: alpha-001
      runtime: go
      api_version: go1
      
      handlers:
      - url: /.*
        script: _go_app
      

      • Create a location for the Go source files.

      % mkdir $HOME/myapp/go

      • Set your GOPATH to the location of your sources

      % export GOPATH=$HOME/myapp/go

      % goapp get github.com/golang/example/appengine-hello

      This command will download the example app to the first path entry in the GOPATH

      % go get -u golang.org/x/oauth2

      % go get -u google.golang.org/cloud/storage

      • Attempt to run your go application

      % goapp serve

      You will see the following compilation error (no stack trace):

      2015/12/23 10:37:07 go-app-builder: Failed parsing input: parser: bad import "syscall" in go/src/golang.org/x/net/ipv6/control_unix.go

      解决方案

      This error is caused by either of two scenarios:

      1) Implicitly importing syscall by importing another package that uses it, as referenced in this related question.

      2) Having your package source files in your GOPATH located in a directory at or below the same level as your project's app.yaml (eg. app.yaml in ~/go, and packages sources in ~/go/gopath/src). If a package like x/net/internal/nettest exists in your GOPATH the syscall import will be parsed by goapp at compile time and throw the compilation error.

      Avoiding these two scenarios should be sufficient to prevent any bad import "syscall" errors or related compilation errors.

      这篇关于坏的导入“系统调用”用于云存储API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆