gollup

command module
v0.0.0-...-dde2fb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 1 Imported by: 0

README

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())
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
option
Package option provides utilities of option handling
Package option provides utilities of option handling
Package selfupdate provides function to update binary Package util provides some utilities
Package selfupdate provides function to update binary Package util provides some utilities

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL