0

I am getting this error when i am packaging my smart contract project in VS code IBM extendion

The Go smart contract is not a subdirectory of the path specified by the environment variable GOPATH. Please correct the environment variable GOPATH.

This is the image of my error and my path variables

https://i.stack.imgur.com/Hqbq1.jpg

shaan bhattacharya
  • 193
  • 1
  • 1
  • 5

1 Answers1

4

First you should confirm that vscode is picking up your GOPATH. If you open the terminal view in vscode and type

echo $GOPATH

to confirm the gopath matches. Then you need to open VSCode to the location of your Go chaincode which must be in the src directory in your go workspace pointed to by your go path. For example here is my go chaincode project called testcc and the actual chaincode source is in mycc

└── testcc
    ├── bin
    ├── pkg
    │   └── linux_amd64
    └── src
        ├── github.com
        ├── golang.org
        └── mycc

located at ~/mycode. Therefore I would have a GOPATH of ~/mycode/testcc and I would open vscode up at the mycc directory. For example I would launch vscode as follows

$ GOPATH=~/mycode/testcc code ~/mycode/testcc/src/mycc
david_k
  • 5,843
  • 2
  • 9
  • 16