Skip to content

Instantly share code, notes, and snippets.

@meblum
meblum / main.go
Created November 8, 2022 18:52 — forked from dopey/main.go
How to generate secure random strings in golang with crypto/rand.
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
"io"
"math/big"
)
@meblum
meblum / unmarshaler.go
Last active February 2, 2021 03:13
Implementation of a custom https://golang.org/pkg/encoding/json/#Unmarshaler to convert a JSON int value to a GO bool value. Returns a formed https://golang.org/pkg/encoding/json/#UnmarshalTypeError when failed. https://play.golang.org/p/oe_JPzDFvke
package main
import (
"encoding/json"
"fmt"
)
type myBool bool
func (b *myBool) UnmarshalJSON(v []byte) error {