fixedwidth alternatives and similar packages
Based on the "Serialization" category.
Alternatively, view fixedwidth alternatives based on common mentions on social networks and blogs.
-
mapstructure
DISCONTINUED. Go library for decoding generic map values into native Go structures and vice versa. -
cbor
CBOR codec (RFC 8949) with CBOR tags, Go struct tags (toarray, keyasint, omitempty), float64/32/16, big.Int, and fuzz tested billions of execs. -
go-capnproto
Cap'n Proto library and parser for go. This is go-capnproto-1.0, and does not have rpc. See https://github.com/zombiezen/go-capnproto2 for 2.0 which has rpc and capabilities. -
bambam
auto-generate capnproto schema from your golang source files. Depends on go-capnproto-1.0 at https://github.com/glycerine/go-capnproto -
go-serializer
:loop: Serialize any custom type or convert any content to []byte or string, for Go Programming Language -
unitpacking
A library for storing unit vectors in a representation that lends itself to saving space on disk. -
go-lctree
go-lctree provides a CLI and Go primitives to serialize and deserialize LeetCode binary trees (e.g. "[5,4,7,3,null,2,null,-1,null,9]").
CodeRabbit: AI Code Reviews for Developers

Do you think we are missing an alternative of fixedwidth or a related project?
README
Fixedwidth
Fixedwidth is a Go package that provides a simple way to define fixed-width data, fast encoding and decoding also is the project's target.
Character encoding supported
UTF-8
Getting Started
Installation
To start using Fixedwidth, run go get
:
$ go get github.com/huydang284/fixedwidth
How we limit a struct field
To limit a struct field, we use fixed
tag.
Example:
type people struct {
Name string `fixed:"10"`
Age int `fixed:"3"`
}
If the value of struct field is longer than the limit that we defined, redundant characters will be truncated.
Otherwise, if the value of struct field is less than the limit, additional spaces will be appended.
Encoding
We can use Marshal
function directly to encode fixed-width data.
package main
import (
"fmt"
"github.com/huydang284/fixedwidth"
)
type people struct {
Name string `fixed:"10"`
Age int `fixed:"3"`
}
func main() {
me := people {
Name: "Huy",
Age: 25,
}
data, _ := fixedwidth.Marshal(me)
fmt.Println(string(data))
}
The result will be:
Huy 25
Decoding
For decoding, we use Unmarshal
.
package main
import (
"fmt"
"github.com/huydang284/fixedwidth"
)
type people struct {
Name string `fixed:"10"`
Age int `fixed:"3"`
}
func main() {
var me people
data := []byte("Huy 25 ")
fixedwidth.Unmarshal(data, &me)
fmt.Printf("%+v", me)
}
The result will be:
{Name:Huy Age:25}
Author
Huy Dang ([email protected])
License
Fixedwidth source code is available under the MIT License.
*Note that all licence references and agreements mentioned in the fixedwidth README section above
are relevant to that project's source code only.