Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 779 Bytes

README.md

File metadata and controls

33 lines (26 loc) · 779 Bytes

Swap out the json implementation by overwriting the types and variables.

Here the standard json implementation is swapped out with jsoniter:

package main

import (
    "github.com/discordpkg/gateway/encoding"
    jsoniter "github.com/json-iterator/go"
)

var j = jsoniter.ConfigCompatibleWithStandardLibrary

func init() {
    encoding.Marshal = j.Marshal
    encoding.Unmarshal = j.Unmarshal
}

The idea here is that you may also switch to a different format such as ETF:

package main

import (
    "github.com/JakeMakesStuff/go-erlpack"
    "github.com/discordpkg/gateway/encoding"
)

func init() {
    encoding.Marshal = erlpack.Pack
    encoding.Unmarshal = erlpack.Unpack
}