0

I have my go installed with ubuntu package. Basics library (fmt etc.) are working correctly.

But I have a real project in /var/www/mygoproject with multiple subfolder ex:

  • ./subfolder1
  • ./lib1
  • ./lib2
  • ./subfolder2

subfolderX contain different go applications and libX contain shared code.

I would like, in subfolderX use import "lib1/package-inside" but I always get the imported and not used error.

What I have to do ?


edit: code of /var/www/project/subproject/folder/alpha.go

package main

import (
    "subprojectA/folder/apackage" //doesnt work
    "./apackage" //works but not the cleanest
)

func main() {

    var sr interface{}
    sr = "tmp"

    apackage.Run(sr)
}
Aurélien B
  • 4,590
  • 3
  • 34
  • 48

1 Answers1

1

The go build system, in the first approximation, resolves import path pth by looking for package named $(basename pth) in directory $GOPATH/src/pth.

It seems to me you're missing the /src/ part.

Useful discussion of GOPATH can be found eg. here, another here

zzzz
  • 87,403
  • 16
  • 175
  • 139
  • I thought I can dodge the /src/ part but it seems I cannot. I rebuild folder with /src/ and /pkg/ subfolder and put all my code in ./src/. then it works – Aurélien B May 02 '13 at 08:11