Skip to content

mpppk/gollup

Repository files navigation

gollup

GitHub Actions codecov GoDoc

gollup is a bundler for golang with tree-shaking.

Caution

Most Go users do not need this tool.
For example, this does not contribute to reducing the binary size.
One of the few use cases is competitive programming, such as atcoder, where only one file can be submitted.

Current status: under development

50+ codes I bundled using gollup are accepted on atcoder.
However, this tool is not yet stable and may generate incorrect code. I'm concerned that users will be penalized on the contest due to a bug in this tool. Please try gollup on the past contest, check the behavior, and consider whether to use it on the contest. When using it on a contest, I recommend that you also prepare other bundling methods such as bundle or manual.

Also, currently gollup does not support the following situations:

Installation

$ go get github.com/mpppk/gollup

Usage

Simple example

$ tree .
.
├── main.go
└── sub.go

main.go:

package main

import "fmt"

func main() {
	v := f()
	fmt.Println(v)
}

sub.go:

package main

func f() int {
	return 42
}

// unusedFunc will not be included in bundled code because this is unused
func unusedFunc() {}
$ gollup > output.go

output.go:

package main

import (
	"fmt"
)

func f() int {
	return 42
}
func main() {
	v := f()
	fmt.Println(v)
}

Multi package example

$ tree .
.
├── lib
│   └── lib.go
└── main.go

main.go:

package main

import (
	"fmt"

	"github.com/mpppk/gollup/testdata/test2/lib"
)

const ANSWER = 42

func main() {
	fmt.Println(F1(), lib.F1())
}

func F1() int {
	return ANSWER
}

lib/lib.go:

package lib

import "math"
const ANSWER = -42

func F1() float64 {
	return math.Abs(ANSWER)
}
$ gollup ./lib . > output.go

output.go:

package main

import (
	"fmt"
	"math"
)

const (
	ANSWER     = 42
	lib_ANSWER = -42
)

func F1() int {
	return ANSWER
}
func lib_F1() float64 {
	return math.Abs(lib_ANSWER)
}
func main() {
	fmt.Println(F1(), lib_F1())
}

About

A bundler for golang with tree-shaking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published