Background: I wrote a feature(in packageA) and don't want anyone see my code. So I installed it into .a file(packageA.a). I use it by below method:
package main
import packageA
func main(){
packageA.Run()
}
Then I do
go tool compile -I lib/ main.go
It can work.
go tool link -o main -L main.o
But when I do this it doesn't work.
I wrote another feature(packageB) in $GOPATH/src/project/packageB
and update main.go
// main.go
package main
import (
"packageA"
_ "project/packageB"
)
func main(){
packageA.Run()
}
exec
go tool compile -I lib/ main.go
but error
can't find import "packageB"
my directory layout
project
main.go
lib/
packageA.a
packageB
xxx.go
Wanted to know if it's good practice to do that and what would be the best way to do that? go tool compile how to import .a file and source code?
Thanks sincerely in advance.