Home:ALL Converter>How to use/distribute a binary package without Go source code

How to use/distribute a binary package without Go source code

Ask Time:2015-05-26T18:10:27         Author:Bryan Toh

Json Formatter

Basically my folder structure is as below:

bin/               
pkg/
    linux_amd64/         
        github.com/user/
            stringutil.a  
src/
    github.com/user/
        hello/
            hello.go   (main file)  
        stringutil/
            stringutil.go

hello.go is the main program that imports some function from stringutil.go.

After running go install, stringutil.a is created under pkg (as above).

My question is, can I run go install again without stringutil.go source since I already have stringutil.a?

I'm a Java programmer and new to Go. Usually in Java, during compilation, we can import the compiled jar file to the classpath and do compilation.

How can I do the same thing in Go? If I have a compiled package, stringutil.a, how can I distribute this file to someone and let them use it without exposing the original source code?

Author:Bryan Toh,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30455537/how-to-use-distribute-a-binary-package-without-go-source-code
yy