A tool to analyze and troubleshoot a Go binary size.

Related tags

Network goweight
Overview

goweight

A tool to analyze and troubleshoot a Go binary size.

For more, see this blog post

Get a breakdown of all modules inside a binary
Supports Go 1.11 modules
Output as JSON for tracking and/or monitoring as part of CI

Quick Start

With Go Modules - Go 1.11 or higher

$ go get github.com/jondot/goweight
$ cd current-project
$ goweight

Without Go Modules - Before Go 1.11

$ git clone https://github.com/jondot/goweight
$ cd goweight
$ go install

$ cd current-project
$ goweight

As an example, here's what goweight has to say about itself:

$ ./goweight
  3.0 MB runtime
  1.6 MB net
  1.4 MB reflect
  1.3 MB gopkg.in/alecthomas/kingpin.v2
  870 kB math/big
  668 kB github.com/alecthomas/template
  628 kB syscall
  626 kB text/template
  550 kB go/ast
  546 kB encoding/json
  509 kB text/template/parse
  495 kB github.com/alecthomas/template/parse
  424 kB time
  402 kB regexp/syntax
  395 kB golang_org/x/net/dns/dnsmessage
  388 kB fmt

Thanks:

To all Contributors - you make this happen, thanks!

Copyright

Copyright (c) 2018 @jondot. See LICENSE for further details.

Issues
  • Making it work on already compiled binaries

    Making it work on already compiled binaries

    I'm trying to use this for fairly complex projects like Kubernetes server components that are already pre-built.

    Is it possible to make this work on compiled binaries like the blog post at https://science.raphael.poss.name/go-executable-size-visualization-with-d3.html explains?

    opened by ahmetb 2
  • How to handle projects created with gb package manager

    How to handle projects created with gb package manager

    I have a project created with gb pacakge manager and how can i execute the goweight command ?I see the following issue when i execute

    # goweight
    2019/04/04 18:12:17 exit status 1
    
    opened by kgrvamsi 2
  • Doesn't work if there's more than one main() function

    Doesn't work if there's more than one main() function

    I know this shouldn't happen, but I have a helper program that builds my project for different GOOS/GOARCH concurrently that resides within the project, along with the main.go.

    If I run goweight, it exits with:

    2019/04/03 10:58:28 exit status 2
    

    Maybe there should be some way to define which .go files should be used to compile, or to exclude?

    opened by maddie 2
  • go get fails

    go get fails

    > go get github.com/jondot/goweight
    package goweight/pkg: unrecognized import path "goweight/pkg" (import path does not begin with hostname)
    
    opened by noobdoesre 2
  • exit status 2

    exit status 2

    I'm trying to use the tool, but it does not work and does not report why:

    $ go get github.com/jondot/goweight
    $ goweight
    2021/08/31 11:00:22 exit status 2
    $ goweight --version
    dev (none)
    
    opened by xaionaro 1
  • Support for build tags

    Support for build tags

    My package imports a quite heavyweight library when certain build tag is specified. It would be nice to able to see how it contributes to the binary size.

    Something like goweight -tags 'use_heavy_lib'

    opened by foxcpp 0
  • Always getting `operation not permitted` all projects

    Always getting `operation not permitted` all projects

    I am getting an error while trying this out on an example project. Any ideas?

    1. $ git clone https://github.com/jondot/goweight
    2. Jump to your project
    3. $ goweight
    4. See the error: operation not permitted

    macOS - Go v1.15.5

    opened by Dentrax 4
  • remove redundant dependencies

    remove redundant dependencies

    I use this tool all the time. As well as a large number of gophers around the world. Therefore, I thought that reducing the number of dependencies would be a very useful step for the development of this project. That's why:

    1. Faster installation, by reducing the number of network requests to get dependencies. On the cheapest VPS, the original goweight was installed in 31.402s, mine in 8.363s. This is almost 4x acceleration
    2. Barely noticeable acceleration of startup by reducing the size of the executable file. It's almost imperceptible in a single run, but small wins add up to big wins when the tool is run hundreds of times every day by thousands of people around the world.
    3. Reproducibility of builds and user safety. Over time, projects are abandoned, APIs change, github may be unavailable, and sometimes developer accounts are hacked to embed malicious functionality into library code. When we are not dependent on third-party solutions, we can be more confident that the project can be compiled without fear of "infection" and / or problems with the inaccessibility of something.

    Binary size reduction on amd64 linux: 5848 B -> 3028 B

    P.S. I would like to further develop and support goweight, which has not seen a release since May 2019. Assigning me as a maintainer will greatly help me improve the quality of the project and add more features to it. thanks

    opened by brualan 4
  • Don't force recompilation

    Don't force recompilation

    This project is most useful it seems for projects which produce large binaries and which have many dependencies. Such projects can take a long time to build. Thus, I suggest removing the -a flag from the build command. I do not know if it provides any value, because it's been there since the first commit. https://github.com/jondot/goweight/blob/624b44a7a73a54fe24a2061cca7030ff8855d488/pkg/goweight.go#L57

    $ go help build
    -a
        force rebuilding of packages that are already up-to-date.
    
    opened by kroppt 0
  • size does not seem to be accurate

    size does not seem to be accurate

    First of all, thanks for sharing this tool, I found it very useful.

    I've been analysing my binaries with this and I see that the sum of all sizes is much more than the final binary size. Is there any explanation to this? is there any way to know how much smaller a certain binary will be if I remove a dependency?

    The tool is still very useful to focus on the biggest contributing dependencies, but sometimes I see a dependency of 6Mb for example, and after removing it completely I see the final binary only decreased 2Mb for example. I'd like to understand where the delta comes from.

    opened by horacimacias 1
  • Quick start instructions are swapped

    Quick start instructions are swapped

    The quick start instructions were correct, but this commit inverted them:

    https://github.com/jondot/goweight/commit/746c1a5c7d649ec5d3faed6f9fe4d687b5c22a91

    I think that commit should be reverted.

    opened by udhos 2
Releases(v1.0.5)
Owner
Dotan J. Nahum
Dotan J. Nahum
Packiffer is a lightweight cross-platform networking toolkit that let you sniff/analyze/inject/filter packets.

Packiffer is a lightweight cross-platform networking toolkit that let you sniff/analyze/inject/filter packets.

Massoud Asadi 52 May 27, 2022
Simple HTTP/HTTPS proxy - designed to be distributed as a self-contained binary that can be dropped in anywhere and run.

Simple Proxy This is a simple HTTP/HTTPS proxy - designed to be distributed as a self-contained binary that can be dropped in anywhere and run. Code b

Jamie Thompson 13 May 9, 2022
Instant, disposable, single-binary web based live chat server. Go + VueJS.

Niltalk Niltalk is a web based disposable chat server. It allows users to create password protected disposable, ephemeral chatrooms and invite peers t

Kailash Nadh 852 Jun 16, 2022
Golang binary for data exfiltration with ICMP protocol

QueenSono ICMP Data Exfiltration A Golang Package for Data Exfiltration with ICMP protocol. QueenSono tool only relies on the fact that ICMP protocol

Ariary 98 Jun 27, 2022
provides alternative to simlinking with a configurable proxy binary

Shim Shim is a standalone binary used for shimming executables instead of relying on symlinks. Shim is based on the chocolatey shim https://docs.choco

Patrick Huber 0 Oct 21, 2021
Implementing SPEEDEX price computation engine in Golang as a standalone binary that exchanges can call

speedex-standalone Implementing SPEEDEX price computation engine in Golang as a standalone binary that exchanges can call. Notes from Geoff About Tato

Samuel Wong 1 Dec 1, 2021
This app brings the Matterbridge binary to your server to connect Nextcloud Talk with other chat services

This app brings the Matterbridge binary to your server to connect Nextcloud Talk with other chat services

Nextcloud 25 Jun 14, 2022
Easy to use arbitrarily-ordered encoding/binary.ByteOrder

byteorder byteorder is a Go module for working with arbitrarily-ordered byte slices. It is useful e.g. when dealing with Modbus wire formats. Installa

andig 0 Dec 5, 2021
Server-tool - A simple tool to run and create Minecraft servers

Server Tool A simple tool to run and maintain different Minecraft servers. This

Jack 1 Jan 6, 2022
This is a tool that allows you to check minecraft names availability, this tool can do around 3000~ names a minute or more!

Checker This is a tool that allows you to check minecraft names availability, this tool can do around 3000~ names a minute or more! Tutorial To instal

null 3 Feb 13, 2022
Traefik config validator: a CLI tool to (syntactically) validate your Traefik configuration filesTraefik config validator: a CLI tool to (syntactically) validate your Traefik configuration files

Traefik Config Validator Note This is currently pre-release software. traefik-config-validator is a CLI tool to (syntactically) validate your Traefik

Thomas Klinger 0 Dec 16, 2021
A tool that makes http requests and outputs the url and the content (optionally to file)

BKK Basic Crawler A tool that makes http requests and outputs the url and the content (optionally to file) How to run.. the tests go test the compiler

Jero Berlin 0 Nov 8, 2021
A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for keywords within the saved content

wayback-keyword-search A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for

null 41 Apr 20, 2022
PinGo is a standalone and feature-rich tool for common IP-based reachability checking tasks. Ping or Trace and Observe in real-time the statistics.

pingo As a network champion from designing and implementing to troubleshooting large scale networks - I know that is usually not easy for administrato

Jerome Amon 2 May 21, 2022
Golang tool to parse netblocks and domain names from SPF and get information about ASN

gospf Example Install go get github.com/incogbyte/gospf # get from releases ht

incogbyte 4 Apr 22, 2022
A C/S Tool to Download Torrent Remotely and Retrieve Files Back Over HTTP at Full Speed without ISP Torrent Limitation.

remote-torrent Download Torrent Remotely and Retrieve Files Over HTTP at Full Speed without ISP Torrent Limitation. This repository is an extension to

Bruce Wang 57 Oct 7, 2021