-3

I am stuck on this tutorial. Nothing happens every time that I navigate to where my file is located and I try the "go run populationapi.go" step. I made a file populationapi.go in my workspace which I already set as the GOPATH variable. I have a windows computer. Which of the three folders should it be in (bin, pkg, or src)? Any ideas about what's going wrong?

https://www.programmableweb.com/news/how-to-get-started-google-actions/how-to/2017/01/31?page=4

2 Answers2

1

According to the documentation, the GOPATH variable should be set to the folder containing bin, pkg, and src.

Here is the example directory layout they give:

GOPATH=/home/user/go

/home/user/go/
    src/
        foo/
            bar/               (go code in package bar)
                x.go
            quux/              (go code in package main)
                y.go
    bin/
        quux                   (installed command)
    pkg/
        linux_amd64/
            foo/
                bar.a          (installed package object)
Harris
  • 1,775
  • 16
  • 19
  • the only thing is that I remember reading that GOPATH should not be set to the GO folder but a different directory... I will give this a try though I must have misunderstood. – user8188965 Jun 20 '17 at 16:07
  • 1
    It shouldn't be set to your Go *installation* directory (that should be your `GOROOT`, not your `GOPATH`). – Adrian Jun 20 '17 at 16:39
1

each go program is a package and it should be in the "src/package-name/main.go" where as package-name is the directory name which is same as your package name

in your case it should be "src/populationapi/main.go"

or whatever package file name you choose

then go to the package directory and run the command "run main.go"

in the tutorial they used "ngrok" utility you need to download and run that to make it work

Piyush Patel
  • 1,212
  • 15
  • 19