Golang Webapp Seed设置失败

huangapple go评论128阅读模式
英文:

Golang Webapp Seed Set up fails

问题

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

我已经成功执行了以下命令的"go get":

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

但是当我运行"go install"时,出现了以下错误:

  1. C:\Users\TestUser\Documents\go\auth0-golang-sample>go install
  2. main.go:4:2: 找不到包"github.com/auth0/auth0-go/examples/regular-web-app/app",在以下任何位置都找不到:C:\Go\src\pkg\github.com\auth0\auth0-go\examples\regular-web-app\app (from $GOROOT)
  3. C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-go\examples\regular-web-app\app (
  4. from $GOPATH)
  5. server.go:4:2: 找不到包"github.com/auth0/auth0-go/examples/regular-web-app/routes/callback",在以下任何位置都找不到:C:\Go\src\pkg\github.com\auth0\auth0-go\examples\regular-web-app\routes\callback (from $GOROOT)
  6. .....
  7. .....

当我尝试"go get github.com/auth0/auth0-go/"时,出现以下错误:

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

然而,当我尝试"go get github.com/auth0/auth0-golang/"时,出现以下错误:

  1. C:\Users\TestUser\Documents\go\auth0-golang-sample>go get github.com/auth0/auth0-golang/
  2. package github.com/auth0/auth0-golang
  3. imports github.com/auth0/auth0-golang
  4. imports github.com/auth0/auth0-golang: C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-golang中没有可构建的Go源文件

在以下路径中创建了文件/文件夹:

  1. C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-golang\
  2. +--examples
  3. +--go-api
  4. --main.go
  5. --README.md
  6. +--regular-web-app
  7. +--app
  8. --app.go
  9. +--public
  10. --app.css
  11. --app.js
  12. +--routes
  13. +--CALLBACK
  14. +--home
  15. +--middlewares
  16. +--user
  17. --templates.go
  18. --main.go
  19. --README.md
  20. --server.go
  21. --.gitignore
  22. --README.md

以下是我的go env:

  1. set GOARCH=amd64
  2. set GOBIN=C:\Users\TestUser\Documents\go\bin
  3. set GOCHAR=6
  4. set GOEXE=.exe
  5. set GOHOSTARCH=amd64
  6. set GOHOSTOS=windows
  7. set GOOS=windows
  8. set GOPATH=C:\Users\TestUser\Documents\go
  9. set GORACE=
  10. set GOROOT=C:\Go
  11. set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
  12. set CC=gcc
  13. set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
  14. set CXX=g++
  15. set CGO_ENABLED=1

我已经被这个问题困扰了几天,非常感谢任何帮助。
感谢@Vonc,我已经克服了最初的困难。
现在go install报错如下:

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

我已经执行了go get golang.org/x/oauth2,结果如下(简化):

  1. C:\Users\TestUser\Documents\go\
  2. +--pkg
  3. +--windows_amd64
  4. +--golang.org
  5. +--x
  6. +--net
  7. +--oauth2
  8. --internal.a
  9. --jws.a
  10. --oauth2.a
  11. +--src
  12. +--golang.org
  13. +--x
  14. +--net
  15. +--oauth2

我已经清理了所有内容并安装了go 1.4,但仍然出现错误undefined oauth2.New,oauth2.Client等。

我尝试了go get github.com/golang/oauth2,结果如下:

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

我真的陷入了困境。

我刚刚找到了解决golang认证问题的答案,这是由于代码更改导致的代码链接

英文:

I am follow the steps in https://auth0.com/docs/server-platforms/golang
and trying to setup the seed project on a Windows 7 box .

I have ABLE to do "go get " for the following;

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

After these when i run go install i get the error;

  1. C:\Users\TestUser\Documents\go\auth0-golang-sample>go install
  2. 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)
  3. C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-go\examples\regular-web-app\app (
  4. from $GOPATH)
  5. 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)
  6. .....
  7. .....

I get the error below when i try " go get github.com/auth0/auth0-go/"

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

However when i try go get github.com/auth0/auth0-golang/

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

The files/folders created however in

  1. C:\Users\TestUser\Documents\go\src\github.com\auth0\auth0-golang\
  2. +--examples
  3. +--go-api
  4. --main.go
  5. --README.md
  6. +--regular-web-app
  7. +--app
  8. --app.go
  9. +--public
  10. --app.css
  11. --app.js
  12. +--routes
  13. +--CALLBACK
  14. +--home
  15. +--middlewares
  16. +--user
  17. --templates.go
  18. --main.go
  19. --README.md
  20. --server.go
  21. --.gitignore
  22. --README.md

Below are my go env

  1. set GOARCH=amd64
  2. set GOBIN=C:\Users\TestUser\Documents\go\bin
  3. set GOCHAR=6
  4. set GOEXE=.exe
  5. set GOHOSTARCH=amd64
  6. set GOHOSTOS=windows
  7. set GOOS=windows
  8. set GOPATH=C:\Users\TestUser\Documents\go
  9. set GORACE=
  10. set GOROOT=C:\Go
  11. set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
  12. set CC=gcc
  13. set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
  14. set CXX=g++
  15. set CGO_ENABLED=1

I have been locked with this issue for days, any help will be much appreciated.
Thanks to @Vonc i've overcome initial huddle.
Now go install spits this error

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

i have already `go get golang.org/x/oauth2'
and the result(simplified)...

  1. C:\Users\TestUser\Documents\go\
  2. +--pkg
  3. +--windows_amd64
  4. +--golang.org
  5. +--x
  6. +--net
  7. +--oauth2
  8. --internal.a
  9. --jws.a
  10. --oauth2.a
  11. +--src
  12. +--golang.org
  13. +--x
  14. +--net
  15. +--oauth2

I have scrubbed all and installed go 1.4 but i still error
undefined oauth2.New, oauth2.Client etc

I had no luck with go get github.com/golang/oauth2 result

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

Am really stuck in a quagmire

I just found the answer to the golang auth issue, this is as a result of code changes link to code

答案1

得分: 6

我刚刚更新了文档和示例。

有两个错误:

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

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

如果可以,请告诉我!

英文:

I've just updated the Docs and the Sample.

There were 2 errors:

  1. Package rename
  2. OAuth2 package completely changed its API so I've updated it to work as intended.

Now, you should be able to do a go get of the project, or just download it into $GO_PATH/src/github.com/auth0 and then do go get ., go run main.go server.go and it should work.

Let me know if it does!

答案2

得分: 2

看起来仓库已经从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中。

  1. package main
  2. import (
  3. "github.com/auth0/auth0-golang/examples/regular-web-app/app"
  4. "github.com/joho/godotenv"
  5. "log"
  6. )

提交一个拉取请求可以让该仓库修复错误的导入。

关于oauth错误:

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

go get golang.org/x/oauth2是不够的,考虑到最近已经修复了net/yyygolang/x/yyyy的包更改(参见提交9b6b761),go get github.com/golang/oauth2应该更好地工作。

英文:

It seems that the repo has been renamed from auth0/auth0-go to: auth0/auth0-golang

You can see that wrong import in auth0/auth0-golang/examples/regular-web-app/main.go, and the app package does exist, but in auth0/auth0-golang/examples/regular-web-app/app/app.go

  1. package main
  2. import (
  3. "github.com/auth0/auth0-go/examples/regular-web-app/app"
  4. "github.com/joho/godotenv"
  5. "log"
  6. )

A Pull Request would allow that repo to fix the wrong import.


Regarding the oauth error:

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

go get golang.org/x/oauth2 isn't enough
go get github.com/golang/oauth2 should work better, considering, as the OP mentions, that it was recently fixed in order to take into account the package change from net/yyy to golang/x/yyyy (see commit 9b6b761).

huangapple
  • 本文由 发表于 2014年12月23日 00:02:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/27606134.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定