【问题标题】:Golang Webapp Seed Set up failsGolang Webapp 种子设置失败
【发布时间】:2014-12-23 23:54:22
【问题描述】:

我按照https://auth0.com/docs/server-platforms/golang 中的步骤进行操作 并尝试在 Windows 7 机器上设置种子项目。

我有 ABLE 可以为以下事情做“去拿”;

github.com/gorilla/mux, golang.org/x/oauth2,github.com/astaxie/beego/session,
get github.com/codegangsta/negroni

在这些之后,当我运行 go install 我得到 error;

C:\Users\TestUser\Documents\go\auth0-golang-sample>go install
main.go:4:2: cannot find package "github.com/auth0/auth0-go/examples/regular-web-app/app" in any of: C:\Go\src\pkg\github.com\auth0\auth0-go\examples\regular-web-app\app (from $GOROOT)
        C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-go\examples\regular-web-app\app (
from $GOPATH)
server.go:4:2: cannot find package "github.com/auth0/auth0-go/examples/regular-web-app/routes/callback" in any of: C:\Go\src\pkg\github.com\auth0\auth0-go\examples\regular-web-app\routes\callback (from $GOROOT)
.....
.....

当我尝试“go get github.com/auth0/auth0-go/”时出现以下错误

C:\Users\TestUser\Documents\go\auth0-golang-sample>go get github.com/auth0/auth0-go/
Username for 'https://github.com': user
Password for 'https://user@github.com':
# cd .; git clone https://github.com/auth0/auth0-go C:\Users\TestUser\Documents\go\src\github.com\a
uth0\auth0-go
Cloning into 'C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-go'...
remote: Repository not found.
fatal: repository 'https://github.com/auth0/auth0-go/' not found
package github.com/auth0/auth0-go: exit status 128

但是当我尝试 去获取 github.com/auth0/auth0-golang/

C:\Users\TestUser\Documents\go\auth0-golang-sample>go get github.com/auth0/auth0-golang/
package github.com/auth0/auth0-golang
        imports github.com/auth0/auth0-golang
        imports github.com/auth0/auth0-golang: no buildable Go source files in C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-golang

然而在

中创建的文件/文件夹
C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-golang\
+--examples
  +--go-api
     --main.go
     --README.md
  +--regular-web-app
     +--app
        --app.go
     +--public
        --app.css
        --app.js
     +--routes
        +--CALLBACK
        +--home
        +--middlewares
        +--user
         --templates.go
      --main.go
      --README.md
      --server.go
--.gitignore
--README.md

以下是我的 go 环境

set GOARCH=amd64
set GOBIN=C:\Users\TestUser\Documents\go\bin
set GOCHAR=6
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\TestUser\Documents\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

我已经被这个问题锁定了好几天,任何帮助将不胜感激。 感谢@Vonc,我已经克服了最初的拥挤。 现在go install 吐出这个错误

# github.com/auth0/auth0-golang/examples/regular-web-app/routes/callback
..\src\github.com\auth0\auth0-golang\examples\regular-web-app\routes\callback\ca
llback.go:17: undefined: oauth2.New
..\src\github.com\auth0\auth0-golang\examples\regular-web-app\routes\callback\ca
llback.go:18: undefined: oauth2.Client
..\src\github.com\auth0\auth0-golang\examples\regular-web-app\routes\callback\ca
llback.go:19: undefined: oauth2.RedirectURL

我已经 `go get golang.org/x/oauth2' 和结果(简化)...

C:\Users\TestUser\Documents\go\
+--pkg
   +--windows_amd64
    +--golang.org
        +--x
           +--net
           +--oauth2
               --internal.a
               --jws.a
            --oauth2.a
+--src
  +--golang.org
    +--x
        +--net
        +--oauth2

我已经全部清理并安装了 go 1.4 但我仍然出错 undefined oauth2.New, oauth2.Client 等

我没有运气去获取 github.com/golang/oauth2 结果

can't load package: package github.com/golang/oauth2: code in directory C:\Users
\TestUser\Documents\go\src\github.com\golang\oauth2 expects import "golang.org/x/oauth2"

我真的陷入了泥潭

我刚刚找到了 golang auth 问题的答案,这是由于代码更改link to code

【问题讨论】:

    标签: git go


    【解决方案1】:

    我刚刚更新了文档和Sample

    有 2 个错误:

    1) 包重命名 2) OAuth2 包完全改变了它的 API,所以我已经更新它以按预期工作。

    现在,您应该可以执行该项目,或者将其下载到$GO_PATH/src/github.com/auth0,然后执行go get .go run main.go server.go,它应该可以工作。

    如果有请告诉我!

    【讨论】:

    • 作者本人的反馈很好。 +1。比我猜测的答案更准确。
    【解决方案2】:

    好像repo已经从auth0/auth0-go重命名为:auth0/auth0-golang

    auth0/auth0-golang/examples/regular-web-app/main.go可以看到错误的导入,app包确实存在,但是在auth0/auth0-golang/examples/regular-web-app/app/app.go

    package main
    
    import (
        "github.com/auth0/auth0-go/examples/regular-web-app/app"
        "github.com/joho/godotenv"
        "log"
    )
    

    Pull Request 将允许该 repo 修复错误的导入。


    关于 oauth 错误:

    # github.com/auth0/auth0-golang/examples/regular-web-app/routes/callback
    ..\src\github.com\auth0\auth0-golang\examples\regular-web-app\routes\callback\callback.go:17:
    undefined: oauth2.New
    

    go get golang.org/x/oauth2 还不够 go get github.com/golang/oauth2 应该更好地工作,考虑到正如 OP 所提到的,它最近已修复以考虑到 package change from net/yyy to golang/x/yyyy(请参阅 commit 9b6b761)。

    【讨论】:

    • VonC,谢谢。正如我所说,我尝试导入 go get github.com/auth0/auth0-golang/ 并且在楼上的 go env 之前出现错误。我应该手动将克隆的文件复制到C:\Users\TestUser\Do cuments\go\src\github.com\auth0\auth0-golang 还是允许 go get 解决这个问题。谢谢
    • @BlowMan 如果您修复引用app 包的regular-web-app/main.go 导入,手动复制将起作用。否则错误会持续存在。
    • 感谢我按照建议完成并清除了错误。当我go install 时,我用另一个错误更新了这个问题。
    • @BlowMan golang.org/x/oauth2 看起来像 1.4 路径 (stackoverflow.com/a/26773479/6309) 你在使用 go1.4 吗?
    • @BlowMan 考虑使用github.com/golang/oauth2,你试过go get github.com/golang/oauth2 吗? (除了go get golang.org/x/oauth2
    猜你喜欢
    • 1970-01-01
    • 2011-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-25
    • 1970-01-01
    • 2021-02-09
    • 1970-01-01
    相关资源
    最近更新 更多