Some Golang types based on builtin. Implements interfaces Value / Scan and MarshalJSON / UnmarshalJSON for simple working with database NULL-values and Base64 encoding / decoding.

Overview

gotypes

Some simple types based on builtin Golang types that implement interfaces for working with DB (Scan / Value) and JSON (Marshal / Unmarshal).

NullUint

Simplified sql.NullInt64 (but unsigned): not struct, based on builtin uint type.

ni := sql.NullInt64{Int64: 32, Valid: true}
// Corresponds to
nu := gotypes.NullUint(32)

ni := sql.NullInt64{Int64: 0, Valid: true}
// Corresponds to
nu := gotypes.NullUint(0)

ni := sql.NullInt64{Int64: 32, Valid: false}
// Corresponds to
nu := gotypes.NullUint(0)

NullString

Simplified sql.NullString: not struct, based on builtin string type.

ni := sql.NullString{String: "example", Valid: true}
// Corresponds to
nu := gotypes.NullString("example")

ni := sql.NullInt64{String: "", Valid: true}
// Corresponds to
nu := gotypes.NullString("")

ni := sql.NullInt64{String: "example", Valid: false}
// Corresponds to
nu := gotypes.NullString("")

Base64

Type for simply decoding / encoding Base64 in JSON-structs.

type Something struct {
    Base gotypes.Base64 `json:"base"`
}

something := Something{Base: gotypes.Base64("decode me please")}

jsonString, err := json.Marshal(something)
if err != nil {
    return err
}
// Base is Base64 encoded string.
fmt.Println(string(jsonString))
// Output:
// {"base":"ZGVjb2RlIG1lIHBsZWFzZQ=="}

var anything Something
if err := json.Unmarshal(jsonString, &anything); err != nil {
    panic(err)
}
// Base has value decoded from Base64 string.
fmt.Println(string(anything.Base))
// Output:
// decode me please
You might also like...
Converts go types no matter what

elastic Converts go types no matter what elastic is a simple library that converts any type to another the best way possible. This is useful when the

Helper functions for the manipulation of slices of all types in Go

go-slices Unlike many other programming languages, Go doesn't provide helper functions for slices in it's core. I felt like this was quite an essentia

Simple, specialised, and efficient binary marshaling

🔌 surge Documentation A library for fast binary (un)marshaling. Designed to be used in Byzantine networks, 🔌 surge never explicitly panics, protects

A simple Slack message tool for the CLI written in Go

heka A simple Slack message tool for the CLI written in Go Report Bug · Request

Sqlyog-password-decoder - Simple decode passwords from .sycs file (SQLyog export connections file)

Decode password: ./sqlyog-password-decoder -str password -action decode Encode p

auto-generate capnproto schema from your golang source files. Depends on go-capnproto-1.0 at https://github.com/glycerine/go-capnproto

bambam: auto-generate capnproto schema from your golang source files. Adding capnproto serialization to an existing Go project used to mean writing a

Golang binary decoder for mapping data into the structure

binstruct Golang binary decoder to structure Install go get -u github.com/ghostiam/binstruct Examples ZIP decoder PNG decoder Use For struct From file

CBOR RFC 7049 (Go/Golang) - safe & fast with standard API + toarray & keyasint, CBOR tags, float64/32/16, fuzz tested.
CBOR RFC 7049 (Go/Golang) - safe & fast with standard API + toarray & keyasint, CBOR tags, float64/32/16, fuzz tested.

CBOR library in Go fxamacker/cbor is a CBOR encoder & decoder in Go. It has a standard API, CBOR tags, options for duplicate map keys, float64→32→16,

Fixed width file parser (encoder/decoder) in GO (golang)

Fixed width file parser (encoder/decoder) for GO (golang) This library is using to parse fixed-width table data like: Name Address

Owner
null
GED - Global-purpose Encoding / Decoding library

GED - Global-purpose Encoding / Decoding library This library lets you use common encoding/decoding schemes and allows you to define custom ones. Use

Noémien Kocher 0 Nov 28, 2021
Go library for decoding generic map values into native Go structures and vice versa.

mapstructure mapstructure is a Go library for decoding generic map values to structures and vice versa, while providing helpful error handling. This l

Mitchell Hashimoto 6.2k Sep 29, 2022
Generate TypeScript interfaces from Go structs/interfaces - useful for JSON RPC

bel Generate TypeScript interfaces from Go structs/interfaces - useful for JSON RPC bel is used in production in https://gitpod.io. Getting started be

Christian Weichel 27 Sep 3, 2022
An optimal, byte-aligned, LZ+RLE hybrid encoder, designed to maximize decoding speed on NMOS 6502 and derived CPUs

TSCrunch TSCrunch is an optimal, byte-aligned, LZ+RLE hybrid encoder, designed to maximize decoding speed on NMOS 6502 and derived CPUs, while keeping

null 26 Jun 10, 2022
Asn.1 BER and DER encoding library for golang.

WARNING This repo has been archived! NO further developement will be made in the foreseen future. asn1 -- import "github.com/PromonLogicalis/asn1" Pac

Logicalis 51 Aug 3, 2022
Fast implementation of base58 encoding on golang.

Fast Implementation of Base58 encoding Fast implementation of base58 encoding in Go. Base algorithm is adapted from https://github.com/trezor/trezor-c

Denis Subbotin 126 Sep 22, 2022
msgpack.org[Go] MessagePack encoding for Golang

MessagePack encoding for Golang ❤️ Uptrace.dev - All-in-one tool to optimize performance and monitor errors & logs Join Discord to ask questions. Docu

Vladimir Mihailenco 1.9k Sep 23, 2022
A high-performance 100% compatible drop-in replacement of "encoding/json"

A high-performance 100% compatible drop-in replacement of "encoding/json" You can also use thrift like JSON using thrift-iterator Benchmark Source cod

Jsoniter 11.3k Sep 22, 2022
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.

csvutil Package csvutil provides fast and idiomatic mapping between CSV and Go (golang) values. This package does not provide a CSV parser itself, it

Jacek Szwec 753 Sep 28, 2022
Encode and decode Go (golang) struct types via protocol buffers.

protostructure protostructure is a Go library for encoding and decoding a struct type over the wire. This library is useful when you want to send arbi

Mitchell Hashimoto 172 Sep 9, 2022