Skip to content

Latest commit

 

History

History
68 lines (41 loc) · 3.2 KB

README.md

File metadata and controls

68 lines (41 loc) · 3.2 KB

Goyp - Build system that protects your Software IP written in Golang

Goyp (pronounced go - eep) is a Golang tool that uses go tool compile and go tool link Golang commands to compile and link your application together with any library that is in Go Object code format or source code format. As well as compile your library to Go Object code to distribute to your users and protect your intellectual property.

Supporting Go Modules and libraries distributed as Go Object code, as those that are produced by go tool compile command

Why?

Well Golang one time had support for creating Go Object file and distribute it to users to protect your IP, but with the Go Modules arrival, they dropped support of this feature, stating that it was very hard to maintain and allegating that "Nobody uses this feature". This disappointed many developers who do care about our intellectual property or our country does not protects our intellectual property from being violated (when distributing in source code format), we ended up using other, more considerate alternatives.

Now I want to support this removed features.

How this is done?

The previous way of distributing Go Object file libraries was with "Binary-only packages", I'm going to take another approach and let users use //go:linkname compiler directive, since this is a very well supported directive with pretty well documentation.

Example:

Suppose the following two Go source code files:

// closed_src/lib.go

package closed_src

import _ "unsafe"

//go:linkname algo example.org/header.Algorithm
func algo() int { ...Your closed source algorithm }
// header/header.go

//goyp:preserve-pkg-sources

package header

import _ "example.org/closed_src" // Provides definition for "Algorithm" function

func Algorithm() int

And this go.mod file:

module example.org

go 1.18

Running the command goyp build will produce a .zip file containing the following files:

|-- closed_src.a     # Go Object file containing binary instructions for package 'closed_src'
|-- go.mod           # Go Module specifying the module and dependencies
|-- header/          # Directory preserved thanks to '//goyp:preserve-pkg-sources' directive
|   |-- header.go    # Unmodified Go source files

This directory can be distributed to users, and they can get them through go get command as usual, only if they are published to a public VCS repository.

Users can develop another libraries or build entire applications using that library as dependency and the goyp build command. Not compromising your sources.

How to distribute my library binary code generated by goyp build?

goyp build produces a zip file containing all of the Object code generated from your Go module, alongside with any directory that contains a go file with the directive //goyp:preserve-pkg-sources. If you want to publish it to a GOPROXY, this file needs to be put inside of a VCS repository, then run the command goyp dist-lib ./path/to/lib.zip inside of the repository, this command will delete any file under "./" and extract the contents of the file, then you need to commit and you are done.

Please follow this guide on how to configure private GOPROXYs.