Skip to content

Instantly share code, notes, and snippets.

// KTTime is an example of a type that is aliased to time, than implements the json marshaling functions.
// This is an example for how to build serialization interopability with kotlin/gson.
package kttime
type KTTime time.Time
func (t KTTime) MarshalJSON() ([]byte, error) {
gt := time.Time(t)
f := gt.Format(ktFormat)
return json.Marshal(f)
import (
"context"
"net/http"
)
type key int
var contextKey = key(22)
func SetUser(usr *User, r *http.Request) {
@kendellfab
kendellfab / role.go
Created June 9, 2022 13:02
Go Enums
type Role int
const (
RoleUnknown Role = iota
_
_
RoleUser
_
_
RoleAdmin