Giter Site home page Giter Site logo

goyp's Introduction

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.

goyp's People

Contributors

otaxhu avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.