Sunday, April 15, 2012

Golang -- using external libraries or third party libraries or third party code

(1) You must set the GOPATH, example in Windows XP
C:> mkdir -p c:\go-others\src
C:> set GOPATH=c:\go-others

(2)  Copy the third-party code under the "c:\go-others\src" folder. Make it organized and neat, example, if your project name is "MyProject" do something like this.
C:> mkdir -p c:\go-others\src\\myclient_a\MyProject
C:> go install\myclient_a\MyProject

(3) You can now use the third-party code,

import ""
import ""


(1) under the MyProject folder you have the  files

- abcd.go
- baaa.go
- ceee.go

each of these files should have the  phrase  "package MyProject" at the beginning or at the top of the file

(2) under the "subpkg" folder you have the
- fooo.go
- saaa.go
- yaaa.go

each of these files should have the phrase "package subpkg" at the beginning or at the top of the file


(1) when the error is "cannot refer to unexported name"

Try the following:
- capitalize the first letter of your function in that package that you wish to call
- it is case-sensitive, check your function call

;) cheers.