2

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;

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

After these when i run go install i get the 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)
.....
.....

I get the error below when i try " 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

However when i try go get 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

The files/folders created however in

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

Below are my go env

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

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

# 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

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

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

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

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"

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

BlowMan
  • 353
  • 1
  • 7
  • 21

2 Answers2

6

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!

mgonto
  • 6,605
  • 2
  • 29
  • 36
  • Great feedback frol the author himself. +1. More precise that my answer which was more a guesswork. – VonC Dec 23 '14 at 23:20
2

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

package main

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

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


Regarding the oauth error:

# 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 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).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • VonC,thanks. As i stated, i tried to import **go get github.com/auth0/auth0-golang/** and i got the error just before the go env upstairs. Should i manually copy the cloned files into the `C:\Users\TestUser\Do cuments\go\src\github.com\auth0\auth0-golang` or rather allow the **go get** to resolve that. Thanks – BlowMan Dec 22 '14 at 19:29
  • @BlowMan a manual copy would work, provided you *also* fix the `regular-web-app/main.go` import referencing the `app` package. Or the error would persists. – VonC Dec 22 '14 at 19:36
  • thanks i did as suggested and cleared error. I have updated the question with another error when i `go install`. – BlowMan Dec 22 '14 at 20:12
  • @BlowMan `golang.org/x/oauth2` looks like an 1.4 path (http://stackoverflow.com/a/26773479/6309) Are you using go1.4? – VonC Dec 22 '14 at 20:26
  • @BlowMan considering https://github.com/golang/oauth2, did you try a `go get github.com/golang/oauth2`? (in addition of the `go get golang.org/x/oauth2`) – VonC Dec 22 '14 at 20:29
  • go version 1.3.3. i tried only go get golang.org/x/oauth2 . i did not try go get github.com/golang/oauth2. Thanks – BlowMan Dec 22 '14 at 20:47
  • @BlowMan Ok. Try the second `go get github.com/golang/oauth2` then. If any issue persists, consider using go1.4 as well just in case it helps. – VonC Dec 22 '14 at 20:52
  • I found the answer after a little combing, it relates to code changes and i have updated the question. Thanks – BlowMan Dec 23 '14 at 05:13
  • @BlowMan Ok, I have included your conclusions in the answer for more visibility. – VonC Dec 23 '14 at 09:15