Cannot find package for shared library

I am trying to use a shared library in go-lang, I am following this blog post: http://blog.ralch.com/tutorial/golang-sharing-libraries/

But when I hit build I get back an error:

simo@simo:~/gopath$ go build -linkshared -o app effe/prova
src/effe/prova/prova.go:3:8: cannot find package "libmath" in any of:
/usr/local/go/src/libmath (from $GOROOT)
/home/simo/gopath/src/libmath (from $GOPATH)

I am pretty new to go, so I will show also my environment...

simo@simo:~/gopath$ pwd
/home/simo/gopath
simo@simo:~/gopath$ echo $GOPATH
/home/simo/gopath
simo@simo:~/gopath$ tree
.
├── pkg
│   └── linux_amd64_dynlink
│       ├── effe
│       │   ├── libmath.a
│       │   └── libmath.shlibname
│       └── libeffe-libmath.so
└── src
    └── effe
        ├── libmath
        │   └── libmath.go
        └── prova
            └── prova.go

7 directories, 5 files
simo@simo:~/gopath$ cat src/effe/libmath/libmath.go 
// filename: libmath.go
package libmath

func Sum(x, y int) int {
    return x + y
}
simo@simo:~/gopath$ cat src/effe/prova/prova.go 
package main

import "libmath"
import "fmt"

func main() {
    fmt.Printf("5 op 10 => %d", libmath.Sum(5, 10))
}
simo@simo:~/gopath$ go install -buildmode=shared -linkshared effe/libmath
simo@simo:~/gopath$ go build -linkshared -o app effe/prova
src/effe/prova/prova.go:3:8: cannot find package "libmath" in any of:
    /usr/local/go/src/libmath (from $GOROOT)
    /home/simo/gopath/src/libmath (from $GOPATH)

What am I doing wrong ?

Answers


The import path for "libmath" is "effe/libmath".

Try to get your build working in the standard build mode before experimenting with more complicated build and execution modes.


Need Your Help

React Form Component onSubmit Handler Not Working

reactjs

I have the following React component:

Doctrine/Symfony entity generator and generating entity from one table

php symfony doctrine-orm symfony-2.3

I have already a few entities, but now a new table appeared in a database, and I'd like to generate an entity on only this one table.