DEV Community 👩‍💻👨‍💻


Posted on

Compile your go app cross-platform easily!

Hello gophers! when you create an app with go, you also need to compile your app for other platforms and architectures. In go, you need to change environment variables for every compile. So i decided to make a simple tool named CCGO (Cross-platform Compile for Go) that does this for us!

For now, it compiles your app to 14 different platform. but you also can make a config yourself!

It works pretty simple. Download the binary from release page and add to your path.

Now we can test the app. Lets create a empty dir and initialize our project with go mod init example. Then we will add a main.go file that contains:

package main

func main() {
  println("Hello World!")
Enter fullscreen mode Exit fullscreen mode

And now, we can test the ccgo. Lets run the ccgo with ccgo example. (the example is the name of the app.)

Example Compiling Photo

It compiled our app successfully. But where is the binaries? CCGO adds the programs to the .ccgo folder. If you can't see the folder in your project root, Make sure you enabled the see hidden file/folders.

Example CCGO Folder Photo

CCGO also creates a sha1 checksum for your binary:
Example Compiled Folder Photo

We also can create our own config. For this, we need to create a file named ccgo.config.json first. Then we can add the configs to the this JSON file. List of the configs with examples are avaible at gitlab repository file.

Thats it! Since I just started yesterday, its current state is not very advanced. Please check the file from gitlab repository if you want to contribute to this project.

Top comments (0)

🌚 Life is too short to browse without dark mode