betteralign - structs field alignment static analyzer for Go

This page summarizes the projects mentioned and recommended in the original post on /r/golang

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • betteralign

    Make your Go programs use less memory (maybe)

  • I've written betteralign, a tool to detect structs that would use less memory if their fields were sorted and optionally sort such fields. Truth be told, there are a few projects already doing this task perfectly such as fieldalignment, maligned and structslop so you might wonder why should you bother with checking this tool at all. This is a fork of an official Go fieldalignment tool and vast majority of the alignment code has remained the same. There are however some notable changes:

  • go

    The Go programming language

  • In case you are wondering why DST and not AST, in general sense AST does not associate comments to nodes, but it holds fixed offsets. Original fieldalignment tool just erases all struct/field/floating comments due to this issue and while there is a CL with a possible fix, it's still a work in progress as of this time.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • maligned

    Tool to detect Go structs that would take less memory if their fields were sorted.

  • I've written betteralign, a tool to detect structs that would use less memory if their fields were sorted and optionally sort such fields. Truth be told, there are a few projects already doing this task perfectly such as fieldalignment, maligned and structslop so you might wonder why should you bother with checking this tool at all. This is a fork of an official Go fieldalignment tool and vast majority of the alignment code has remained the same. There are however some notable changes:

  • structslop

    structslop is a static analyzer for Go that recommends struct field rearrangements to provide for maximum space/allocation efficiency.

  • I've written betteralign, a tool to detect structs that would use less memory if their fields were sorted and optionally sort such fields. Truth be told, there are a few projects already doing this task perfectly such as fieldalignment, maligned and structslop so you might wonder why should you bother with checking this tool at all. This is a fork of an official Go fieldalignment tool and vast majority of the alignment code has remained the same. There are however some notable changes:

  • dst

    Decorated Syntax Tree - manipulate Go source with perfect fidelity.

  • Retaining comments has been done with using DST (Decorated Syntax Tree) with decorating regular AST. Sadly when using DST we cannot use "fix" mode with SuggestedFixes, but we have to print whole DST to retain decorations. Leading/ending comment positioning isn't well retained in some cases and it's still a work in progress.

  • goimports

    [mirror] Go Tools (by golang)

  • For more gopls settings, you can see files in this folder: https://github.com/golang/tools/tree/master/gopls/doc

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • GitHub - orijtech/structslop: structslop is a static analyzer for Go that recommends struct field rearrangements to provide for maximum space/allocation efficiency.

    4 projects | /r/golang | 25 Mar 2023
  • Linter for explicit hint to interface which gets implemented.

    2 projects | /r/golang | 26 Jan 2023
  • Abusing Go's Infrastructure

    3 projects | news.ycombinator.com | 25 May 2024
  • Proposal: Add "SIMD" package to standard library

    1 project | news.ycombinator.com | 20 May 2024
  • Golang is evil on shitty networks

    1 project | news.ycombinator.com | 19 May 2024