upwork/golang-upwork

import "github.com/mnovozhylov/randstr" is a program, not an importable package

jkolobok opened this issue · 10 comments

I'm new to golang, so it's likely I'm doing something incorrectly, but I created a new project and copied en example. When I try to run it I get:

GOROOT=/usr/local/Cellar/go/1.16.2/libexec #gosetup
GOPATH=/Users/jkolobok/go #gosetup
/usr/local/Cellar/go/1.16.2/libexec/bin/go build -o /private/var/folders/92/54vm31nx447_0rnyj0882yv40000gn/T/___1go_build_ dev366.com/jobfinder #gosetup
../../../pkg/mod/github.com/mnovozhylov/oauth@v0.0.0-20190507082605-322a3a82211c/oauth.go:59:2: import "github.com/mnovozhylov/randstr" is a program, not an importable package

Compilation finished with exit code 1

Any idea how to fix this?

hi @jkolobok ,
looks like a kind of local or compilation issue - the project doesn't contain such import.
Please, try to load the latest version and follow the steps described in the README

go-get-job.zip
here is an example. it uses go modules

@mnovozhylov it's a transitive dependency from github.com/mnovozhylov/oauth@v0.0.0-20190507082605-322a3a82211c/oauth.go

looks like it's referencing v1.0.2 because version 1.0.3's tag doesn't have 'v' in it's name

ok fixed it by doing go get github.com/mnovozhylov/randstr@1.0.3
but worth fixing the tag name to make it work automatically

@jkolobok , that's interesting.
Could you provide all steps you follow, I'll try to reproduce from scratch? (including go version you use)

Ok, seems I managed to reproduce it. Could you please try once again?
p.s. my previous question is still actual - so, I can verify your steps once again on my end as well.

I use GoLand, but I guess it doesn't matter

  1. Create a new "go modules" project.
  2. it creates a new project with go.mod file
    module awesomeProject
  3. add dependency go get -v github.com/upwork/golang-upwork
  4. create a new main file and copy& paste myapp.go from the example/
  5. run go build

also you can run go mod tidy it adds intermediate dependencies to go.mod

also a nice to have would be to set a version tag to github.com/mnovozhylov/oauth
right now it references a commit