15

I've installed the latest version of Go on my local machine, downloaded the source code from https://github.com/rrrkren/topshot-sales, and placed the project code in my GOPATH.

When I run it go run go/main.go in my command prompt, I get these errors

go\main.go:8:2: no required module provides package github.com/onflow/flow-go-sdk/client: go.mod file not found in current directory or any parent directory; see 'go help modules'
go\main.go:6:2: no required module provides package github.com/rrrkren/topshot-sales/topshot: go.mod file not found in current directory or any parent directory; see 'go help modules'
go\main.go:9:2: no required module provides package google.golang.org/grpc: go.mod file not found in current directory or any parent directory; see 'go help modules'

Even though the go.mod file is located in the current directory. I would like to be able to download this project and keep it on my local machine, so I can edit the source code whenever I want. How can I do that?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Michael Worden
  • 173
  • 1
  • 1
  • 6
  • 2
    Read [Get Started with Go](https://golang.org/doc/tutorial/getting-started). The tutorial goes through the steps of writing a simple program with external dependencies. [How to Write Go Code](https://golang.org/doc/code) is another good tutorial. – Charlie Tumahai Mar 22 '21 at 04:25

3 Answers3

25

This is what worked for me.

Step 1. Delete any previous Go version if you are doubtful about having it configured properly.

Step 2. Install new Go version. Download the binary release (Go) from here Go Binary Download

Note: In order to delete and install the new Go version you can use these steps - Go Deletion and Installation, they worked for me. Also the version I am currently using is 1.16.3.

Step 3. After completing step 1 and step 2, run the following command in a terminal:

go env -w GO111MODULE=auto

This should do it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shubham Arora
  • 807
  • 9
  • 10
8

You should not need a GOPATH environment variable with Go 1.16. Only:

  • GO111MODULE=on (won't be needed in Go 1.17 or 1.18)
  • GOPROXY=https://proxy.golang.org,direct
  • GOROOT=C:\path\to\go

(GOROOT unless you have installed Go in its default folder: %USERPROFILE%\go)

I tried:

D:\git> git clone https://github.com/rrrkren/topshot-sales
Cloning into 'topshot-sales'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 25 (delta 9), reused 21 (delta 6), pack-reused 0
Receiving objects: 100% (25/25), 16.95 KiB | 5.65 MiB/s, done.
Resolving deltas: 100% (9/9), done.

D:\git> cd topshot-sales

D:\git\topshot-sales> go run main.go
go: downloading github.com/onflow/flow-go-sdk v0.10.0
...
go: downloading gopkg.in/yaml.v2 v2.2.5
panic: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 35.193.214.129:9000: i/o timeout"

goroutine 1 [running]:
main.handleErr(...)
        D:/git/topshot-sales/main.go:14
main.main()
        D:/git/topshot-sales/main.go:23 +0x805
exit status 2

No error about go.mod, only a runtime execution error.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes got to this point after looking more into it. Looks like there's still some issues in the repository as of now. Thanks for the help. – Michael Worden Mar 22 '21 at 20:02
0

If you're on macOS, run the following command first and then retry:

xcode-select --install

Reference: Why am I getting an “invalid active developer path” when attempting to use Git after upgrading to macOS Monterey?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dimi Ansari
  • 310
  • 3
  • 16