How to set-up go env properly

96 views
Skip to first unread message

Prabhu Chawandi

unread,
Jan 22, 2020, 4:52:41 AM1/22/20
to golang-nuts
Hello,

   I am setting up my go project directories to test. I have set up like bellow
and my GOPATH is testexercise. Application builds fine, when I run from src/github.com/arpsch/app/ 

But when I try to run go test handler from app folder, I am getting below error . How to organize properly.

app>$go test handler

Error:
can't load package: package handler: cannot find package "handler" in any of:
        c:\go\src\handler (from $GOROOT)
        C:\Users\pchawandi\projects\go\src\handler (from $GOPATH)
        C:\Users\pchawandi\projects\app\src\handler

Folder structure: 
testexercise
├── README.md
└── src
    └── github.com
        └── arpsch
            └── app
                ├── handler
                │   ├── handler.go
                │   ├── handler_test.go
                │   └── testData
                │       └── 1.json
                ├── main.go
                ├── proxy
                │   └── proxy.go
                ├── server
                ├── utils
                │   ├── utils.go
                │   └── utils_test.go

Volker Dobler

unread,
Jan 23, 2020, 12:12:08 AM1/23/20
to golang-nuts
You either need the full import path of the package to test or a simple

    $ go test

V.
Reply all
Reply to author
Forward
0 new messages