id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
143,200
uber/ringpop-go
swim/node.go
SetIdentity
func (n *Node) SetIdentity(identity string) error { return n.memberlist.SetLocalLabel(membership.IdentityLabelKey, identity) }
go
func (n *Node) SetIdentity(identity string) error { return n.memberlist.SetLocalLabel(membership.IdentityLabelKey, identity) }
[ "func", "(", "n", "*", "Node", ")", "SetIdentity", "(", "identity", "string", ")", "error", "{", "return", "n", ".", "memberlist", ".", "SetLocalLabel", "(", "membership", ".", "IdentityLabelKey", ",", "identity", ")", "\n", "}" ]
// SetIdentity changes the identity of the local node. This will change the // state of the local node and will be gossiped around in the network.
[ "SetIdentity", "changes", "the", "identity", "of", "the", "local", "node", ".", "This", "will", "change", "the", "state", "of", "the", "local", "node", "and", "will", "be", "gossiped", "around", "in", "the", "network", "." ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/node.go#L579-L581
143,201
uber/ringpop-go
events/events.go
AddListener
func (a *sharedEventEmitter) AddListener(l EventListener) bool { if l == nil { // do not register nil listener, will cause nil pointer dereference during // event emitting return false } a.listenersLock.Lock() defer a.listenersLock.Unlock() // Check if listener is already registered for _, listener := ran...
go
func (a *sharedEventEmitter) AddListener(l EventListener) bool { if l == nil { // do not register nil listener, will cause nil pointer dereference during // event emitting return false } a.listenersLock.Lock() defer a.listenersLock.Unlock() // Check if listener is already registered for _, listener := ran...
[ "func", "(", "a", "*", "sharedEventEmitter", ")", "AddListener", "(", "l", "EventListener", ")", "bool", "{", "if", "l", "==", "nil", "{", "// do not register nil listener, will cause nil pointer dereference during", "// event emitting", "return", "false", "\n", "}", ...
// AddListener adds a listener to the EventEmitter. Events emitted on this // emitter will be invoked on the listener. The return value indicates if the // listener has been added or not. It can't be added if it is already added and // therefore registered to receive events
[ "AddListener", "adds", "a", "listener", "to", "the", "EventEmitter", ".", "Events", "emitted", "on", "this", "emitter", "will", "be", "invoked", "on", "the", "listener", ".", "The", "return", "value", "indicates", "if", "the", "listener", "has", "been", "add...
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/events/events.go#L70-L98
143,202
uber/ringpop-go
events/events.go
RemoveListener
func (a *sharedEventEmitter) RemoveListener(l EventListener) bool { a.listenersLock.Lock() defer a.listenersLock.Unlock() for i := range a.listeners { if a.listeners[i] == l { // create a new list excluding the listener that needs removal listenersCopy := make([]EventListener, 0, len(a.listeners)-1) list...
go
func (a *sharedEventEmitter) RemoveListener(l EventListener) bool { a.listenersLock.Lock() defer a.listenersLock.Unlock() for i := range a.listeners { if a.listeners[i] == l { // create a new list excluding the listener that needs removal listenersCopy := make([]EventListener, 0, len(a.listeners)-1) list...
[ "func", "(", "a", "*", "sharedEventEmitter", ")", "RemoveListener", "(", "l", "EventListener", ")", "bool", "{", "a", ".", "listenersLock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "listenersLock", ".", "Unlock", "(", ")", "\n\n", "for", "i", ":...
// RemoveListener removes a listener from the EventEmitter. Subsequent calls to // EmitEvent will not cause HandleEvent to be called on this listener. The // return value indicates if a listener has been removed or not. The listener // can't be removed if it was not present before.
[ "RemoveListener", "removes", "a", "listener", "from", "the", "EventEmitter", ".", "Subsequent", "calls", "to", "EmitEvent", "will", "not", "cause", "HandleEvent", "to", "be", "called", "on", "this", "listener", ".", "The", "return", "value", "indicates", "if", ...
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/events/events.go#L104-L121
143,203
uber/ringpop-go
events/events.go
EmitEvent
func (a *AsyncEventEmitter) EmitEvent(event Event) { a.listenersLock.RLock() for _, listener := range a.listeners { go listener.HandleEvent(event) } a.listenersLock.RUnlock() }
go
func (a *AsyncEventEmitter) EmitEvent(event Event) { a.listenersLock.RLock() for _, listener := range a.listeners { go listener.HandleEvent(event) } a.listenersLock.RUnlock() }
[ "func", "(", "a", "*", "AsyncEventEmitter", ")", "EmitEvent", "(", "event", "Event", ")", "{", "a", ".", "listenersLock", ".", "RLock", "(", ")", "\n", "for", "_", ",", "listener", ":=", "range", "a", ".", "listeners", "{", "go", "listener", ".", "Ha...
// EmitEvent will send the event to all registered listeners
[ "EmitEvent", "will", "send", "the", "event", "to", "all", "registered", "listeners" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/events/events.go#L130-L136
143,204
uber/ringpop-go
swim/memberlist_iter.go
newMemberlistIter
func newMemberlistIter(m *memberlist) *memberlistIter { iter := &memberlistIter{ m: m, currentIndex: -1, currentRound: 0, } iter.m.Shuffle() return iter }
go
func newMemberlistIter(m *memberlist) *memberlistIter { iter := &memberlistIter{ m: m, currentIndex: -1, currentRound: 0, } iter.m.Shuffle() return iter }
[ "func", "newMemberlistIter", "(", "m", "*", "memberlist", ")", "*", "memberlistIter", "{", "iter", ":=", "&", "memberlistIter", "{", "m", ":", "m", ",", "currentIndex", ":", "-", "1", ",", "currentRound", ":", "0", ",", "}", "\n\n", "iter", ".", "m", ...
// NewMemberlistIter returns a new MemberlistIter
[ "NewMemberlistIter", "returns", "a", "new", "MemberlistIter" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist_iter.go#L36-L46
143,205
uber/ringpop-go
swim/memberlist_iter.go
Next
func (i *memberlistIter) Next() (*Member, bool) { maxToVisit := i.m.NumMembers() visited := make(map[string]bool) for len(visited) < maxToVisit { i.currentIndex++ if i.currentIndex >= i.m.NumMembers() { i.currentIndex = 0 i.currentRound++ i.m.Shuffle() } member := i.m.MemberAt(i.currentIndex) v...
go
func (i *memberlistIter) Next() (*Member, bool) { maxToVisit := i.m.NumMembers() visited := make(map[string]bool) for len(visited) < maxToVisit { i.currentIndex++ if i.currentIndex >= i.m.NumMembers() { i.currentIndex = 0 i.currentRound++ i.m.Shuffle() } member := i.m.MemberAt(i.currentIndex) v...
[ "func", "(", "i", "*", "memberlistIter", ")", "Next", "(", ")", "(", "*", "Member", ",", "bool", ")", "{", "maxToVisit", ":=", "i", ".", "m", ".", "NumMembers", "(", ")", "\n", "visited", ":=", "make", "(", "map", "[", "string", "]", "bool", ")",...
// Next returns the next pingable member in the member list, if it // visits all members but none are pingable returns nil, false
[ "Next", "returns", "the", "next", "pingable", "member", "in", "the", "member", "list", "if", "it", "visits", "all", "members", "but", "none", "are", "pingable", "returns", "nil", "false" ]
6475220d53092c8264fc6ce9416a351c960fe9fc
https://github.com/uber/ringpop-go/blob/6475220d53092c8264fc6ce9416a351c960fe9fc/swim/memberlist_iter.go#L50-L72
143,206
beanstalkd/go-beanstalk
conn.go
Dial
func Dial(network, addr string) (*Conn, error) { return DialTimeout(network, addr, DefaultDialTimeout) }
go
func Dial(network, addr string) (*Conn, error) { return DialTimeout(network, addr, DefaultDialTimeout) }
[ "func", "Dial", "(", "network", ",", "addr", "string", ")", "(", "*", "Conn", ",", "error", ")", "{", "return", "DialTimeout", "(", "network", ",", "addr", ",", "DefaultDialTimeout", ")", "\n", "}" ]
// Dial connects addr on the given network using net.DialTimeout // with a default timeout of 10s and then returns a new Conn for the connection.
[ "Dial", "connects", "addr", "on", "the", "given", "network", "using", "net", ".", "DialTimeout", "with", "a", "default", "timeout", "of", "10s", "and", "then", "returns", "a", "new", "Conn", "for", "the", "connection", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L52-L54
143,207
beanstalkd/go-beanstalk
conn.go
DialTimeout
func DialTimeout(network, addr string, timeout time.Duration) (*Conn, error) { dialer := &net.Dialer{ Timeout: timeout, KeepAlive: DefaultKeepAlivePeriod, } c, err := dialer.Dial(network, addr) if err != nil { return nil, err } return NewConn(c), nil }
go
func DialTimeout(network, addr string, timeout time.Duration) (*Conn, error) { dialer := &net.Dialer{ Timeout: timeout, KeepAlive: DefaultKeepAlivePeriod, } c, err := dialer.Dial(network, addr) if err != nil { return nil, err } return NewConn(c), nil }
[ "func", "DialTimeout", "(", "network", ",", "addr", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "Conn", ",", "error", ")", "{", "dialer", ":=", "&", "net", ".", "Dialer", "{", "Timeout", ":", "timeout", ",", "KeepAlive", ":", "D...
// DialTimeout connects addr on the given network using net.DialTimeout // with a supplied timeout and then returns a new Conn for the connection.
[ "DialTimeout", "connects", "addr", "on", "the", "given", "network", "using", "net", ".", "DialTimeout", "with", "a", "supplied", "timeout", "and", "then", "returns", "a", "new", "Conn", "for", "the", "connection", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L58-L68
143,208
beanstalkd/go-beanstalk
conn.go
printLine
func (c *Conn) printLine(cmd string, args ...interface{}) { io.WriteString(c.c.W, cmd) for _, a := range args { c.c.W.Write(space) fmt.Fprint(c.c.W, a) } c.c.W.Write(crnl) }
go
func (c *Conn) printLine(cmd string, args ...interface{}) { io.WriteString(c.c.W, cmd) for _, a := range args { c.c.W.Write(space) fmt.Fprint(c.c.W, a) } c.c.W.Write(crnl) }
[ "func", "(", "c", "*", "Conn", ")", "printLine", "(", "cmd", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "io", ".", "WriteString", "(", "c", ".", "c", ".", "W", ",", "cmd", ")", "\n", "for", "_", ",", "a", ":=", "range", "a...
// does not flush
[ "does", "not", "flush" ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L129-L136
143,209
beanstalkd/go-beanstalk
conn.go
Delete
func (c *Conn) Delete(id uint64) error { r, err := c.cmd(nil, nil, nil, "delete", id) if err != nil { return err } _, err = c.readResp(r, false, "DELETED") return err }
go
func (c *Conn) Delete(id uint64) error { r, err := c.cmd(nil, nil, nil, "delete", id) if err != nil { return err } _, err = c.readResp(r, false, "DELETED") return err }
[ "func", "(", "c", "*", "Conn", ")", "Delete", "(", "id", "uint64", ")", "error", "{", "r", ",", "err", ":=", "c", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// Delete deletes the given job.
[ "Delete", "deletes", "the", "given", "job", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L171-L178
143,210
beanstalkd/go-beanstalk
conn.go
Bury
func (c *Conn) Bury(id uint64, pri uint32) error { r, err := c.cmd(nil, nil, nil, "bury", id, pri) if err != nil { return err } _, err = c.readResp(r, false, "BURIED") return err }
go
func (c *Conn) Bury(id uint64, pri uint32) error { r, err := c.cmd(nil, nil, nil, "bury", id, pri) if err != nil { return err } _, err = c.readResp(r, false, "BURIED") return err }
[ "func", "(", "c", "*", "Conn", ")", "Bury", "(", "id", "uint64", ",", "pri", "uint32", ")", "error", "{", "r", ",", "err", ":=", "c", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ",", "id", ",", "pri", ")", "\n", "if", ...
// Bury places the given job in a holding area in the job's tube and // sets its priority to pri. The job will not be scheduled again until it // has been kicked; see also the documentation of Kick.
[ "Bury", "places", "the", "given", "job", "in", "a", "holding", "area", "in", "the", "job", "s", "tube", "and", "sets", "its", "priority", "to", "pri", ".", "The", "job", "will", "not", "be", "scheduled", "again", "until", "it", "has", "been", "kicked",...
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L196-L203
143,211
beanstalkd/go-beanstalk
conn.go
Peek
func (c *Conn) Peek(id uint64) (body []byte, err error) { r, err := c.cmd(nil, nil, nil, "peek", id) if err != nil { return nil, err } return c.readResp(r, true, "FOUND %d", &id) }
go
func (c *Conn) Peek(id uint64) (body []byte, err error) { r, err := c.cmd(nil, nil, nil, "peek", id) if err != nil { return nil, err } return c.readResp(r, true, "FOUND %d", &id) }
[ "func", "(", "c", "*", "Conn", ")", "Peek", "(", "id", "uint64", ")", "(", "body", "[", "]", "byte", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "c", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ",", "id", ")...
// Peek gets a copy of the specified job from the server.
[ "Peek", "gets", "a", "copy", "of", "the", "specified", "job", "from", "the", "server", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L229-L235
143,212
beanstalkd/go-beanstalk
conn.go
Stats
func (c *Conn) Stats() (map[string]string, error) { r, err := c.cmd(nil, nil, nil, "stats") if err != nil { return nil, err } body, err := c.readResp(r, true, "OK") return parseDict(body), err }
go
func (c *Conn) Stats() (map[string]string, error) { r, err := c.cmd(nil, nil, nil, "stats") if err != nil { return nil, err } body, err := c.readResp(r, true, "OK") return parseDict(body), err }
[ "func", "(", "c", "*", "Conn", ")", "Stats", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "r", ",", "err", ":=", "c", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ")", "\n", "if", "err", ...
// Stats retrieves global statistics from the server.
[ "Stats", "retrieves", "global", "statistics", "from", "the", "server", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L238-L245
143,213
beanstalkd/go-beanstalk
conn.go
StatsJob
func (c *Conn) StatsJob(id uint64) (map[string]string, error) { r, err := c.cmd(nil, nil, nil, "stats-job", id) if err != nil { return nil, err } body, err := c.readResp(r, true, "OK") return parseDict(body), err }
go
func (c *Conn) StatsJob(id uint64) (map[string]string, error) { r, err := c.cmd(nil, nil, nil, "stats-job", id) if err != nil { return nil, err } body, err := c.readResp(r, true, "OK") return parseDict(body), err }
[ "func", "(", "c", "*", "Conn", ")", "StatsJob", "(", "id", "uint64", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "r", ",", "err", ":=", "c", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ",", "i...
// StatsJob retrieves statistics about the given job.
[ "StatsJob", "retrieves", "statistics", "about", "the", "given", "job", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L248-L255
143,214
beanstalkd/go-beanstalk
conn.go
ListTubes
func (c *Conn) ListTubes() ([]string, error) { r, err := c.cmd(nil, nil, nil, "list-tubes") if err != nil { return nil, err } body, err := c.readResp(r, true, "OK") return parseList(body), err }
go
func (c *Conn) ListTubes() ([]string, error) { r, err := c.cmd(nil, nil, nil, "list-tubes") if err != nil { return nil, err } body, err := c.readResp(r, true, "OK") return parseList(body), err }
[ "func", "(", "c", "*", "Conn", ")", "ListTubes", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "r", ",", "err", ":=", "c", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", ...
// ListTubes returns the names of the tubes that currently // exist on the server.
[ "ListTubes", "returns", "the", "names", "of", "the", "tubes", "that", "currently", "exist", "on", "the", "server", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/conn.go#L259-L266
143,215
beanstalkd/go-beanstalk
tubeset.go
NewTubeSet
func NewTubeSet(c *Conn, name ...string) *TubeSet { ts := &TubeSet{c, make(map[string]bool)} for _, s := range name { ts.Name[s] = true } return ts }
go
func NewTubeSet(c *Conn, name ...string) *TubeSet { ts := &TubeSet{c, make(map[string]bool)} for _, s := range name { ts.Name[s] = true } return ts }
[ "func", "NewTubeSet", "(", "c", "*", "Conn", ",", "name", "...", "string", ")", "*", "TubeSet", "{", "ts", ":=", "&", "TubeSet", "{", "c", ",", "make", "(", "map", "[", "string", "]", "bool", ")", "}", "\n", "for", "_", ",", "s", ":=", "range",...
// NewTubeSet returns a new TubeSet representing the given names.
[ "NewTubeSet", "returns", "a", "new", "TubeSet", "representing", "the", "given", "names", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tubeset.go#L15-L21
143,216
beanstalkd/go-beanstalk
tubeset.go
Reserve
func (t *TubeSet) Reserve(timeout time.Duration) (id uint64, body []byte, err error) { r, err := t.Conn.cmd(nil, t, nil, "reserve-with-timeout", dur(timeout)) if err != nil { return 0, nil, err } body, err = t.Conn.readResp(r, true, "RESERVED %d", &id) if err != nil { return 0, nil, err } return id, body, ni...
go
func (t *TubeSet) Reserve(timeout time.Duration) (id uint64, body []byte, err error) { r, err := t.Conn.cmd(nil, t, nil, "reserve-with-timeout", dur(timeout)) if err != nil { return 0, nil, err } body, err = t.Conn.readResp(r, true, "RESERVED %d", &id) if err != nil { return 0, nil, err } return id, body, ni...
[ "func", "(", "t", "*", "TubeSet", ")", "Reserve", "(", "timeout", "time", ".", "Duration", ")", "(", "id", "uint64", ",", "body", "[", "]", "byte", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "t", ".", "Conn", ".", "cmd", "(", "nil", ...
// Reserve reserves and returns a job from one of the tubes in t. If no // job is available before time timeout has passed, Reserve returns a // ConnError recording ErrTimeout. // // Typically, a client will reserve a job, perform some work, then delete // the job with Conn.Delete.
[ "Reserve", "reserves", "and", "returns", "a", "job", "from", "one", "of", "the", "tubes", "in", "t", ".", "If", "no", "job", "is", "available", "before", "time", "timeout", "has", "passed", "Reserve", "returns", "a", "ConnError", "recording", "ErrTimeout", ...
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tubeset.go#L29-L39
143,217
beanstalkd/go-beanstalk
tube.go
Put
func (t *Tube) Put(body []byte, pri uint32, delay, ttr time.Duration) (id uint64, err error) { r, err := t.Conn.cmd(t, nil, body, "put", pri, dur(delay), dur(ttr)) if err != nil { return 0, err } _, err = t.Conn.readResp(r, false, "INSERTED %d", &id) if err != nil { return 0, err } return id, nil }
go
func (t *Tube) Put(body []byte, pri uint32, delay, ttr time.Duration) (id uint64, err error) { r, err := t.Conn.cmd(t, nil, body, "put", pri, dur(delay), dur(ttr)) if err != nil { return 0, err } _, err = t.Conn.readResp(r, false, "INSERTED %d", &id) if err != nil { return 0, err } return id, nil }
[ "func", "(", "t", "*", "Tube", ")", "Put", "(", "body", "[", "]", "byte", ",", "pri", "uint32", ",", "delay", ",", "ttr", "time", ".", "Duration", ")", "(", "id", "uint64", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "t", ".", "Conn...
// Put puts a job into tube t with priority pri and TTR ttr, and returns // the id of the newly-created job. If delay is nonzero, the server will // wait the given amount of time after returning to the client and before // putting the job into the ready queue.
[ "Put", "puts", "a", "job", "into", "tube", "t", "with", "priority", "pri", "and", "TTR", "ttr", "and", "returns", "the", "id", "of", "the", "newly", "-", "created", "job", ".", "If", "delay", "is", "nonzero", "the", "server", "will", "wait", "the", "...
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tube.go#L18-L28
143,218
beanstalkd/go-beanstalk
tube.go
PeekDelayed
func (t *Tube) PeekDelayed() (id uint64, body []byte, err error) { r, err := t.Conn.cmd(t, nil, nil, "peek-delayed") if err != nil { return 0, nil, err } body, err = t.Conn.readResp(r, true, "FOUND %d", &id) if err != nil { return 0, nil, err } return id, body, nil }
go
func (t *Tube) PeekDelayed() (id uint64, body []byte, err error) { r, err := t.Conn.cmd(t, nil, nil, "peek-delayed") if err != nil { return 0, nil, err } body, err = t.Conn.readResp(r, true, "FOUND %d", &id) if err != nil { return 0, nil, err } return id, body, nil }
[ "func", "(", "t", "*", "Tube", ")", "PeekDelayed", "(", ")", "(", "id", "uint64", ",", "body", "[", "]", "byte", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "t", ".", "Conn", ".", "cmd", "(", "t", ",", "nil", ",", "nil", ",", "\""...
// PeekDelayed gets a copy of the delayed job that is next to be // put in t's ready queue.
[ "PeekDelayed", "gets", "a", "copy", "of", "the", "delayed", "job", "that", "is", "next", "to", "be", "put", "in", "t", "s", "ready", "queue", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tube.go#L45-L55
143,219
beanstalkd/go-beanstalk
tube.go
Kick
func (t *Tube) Kick(bound int) (n int, err error) { r, err := t.Conn.cmd(t, nil, nil, "kick", bound) if err != nil { return 0, err } _, err = t.Conn.readResp(r, false, "KICKED %d", &n) if err != nil { return 0, err } return n, nil }
go
func (t *Tube) Kick(bound int) (n int, err error) { r, err := t.Conn.cmd(t, nil, nil, "kick", bound) if err != nil { return 0, err } _, err = t.Conn.readResp(r, false, "KICKED %d", &n) if err != nil { return 0, err } return n, nil }
[ "func", "(", "t", "*", "Tube", ")", "Kick", "(", "bound", "int", ")", "(", "n", "int", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "t", ".", "Conn", ".", "cmd", "(", "t", ",", "nil", ",", "nil", ",", "\"", "\"", ",", "bound", ")...
// Kick takes up to bound jobs from the holding area and moves them into // the ready queue, then returns the number of jobs moved. Jobs will be // taken in the order in which they were last buried.
[ "Kick", "takes", "up", "to", "bound", "jobs", "from", "the", "holding", "area", "and", "moves", "them", "into", "the", "ready", "queue", "then", "returns", "the", "number", "of", "jobs", "moved", ".", "Jobs", "will", "be", "taken", "in", "the", "order", ...
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tube.go#L74-L84
143,220
beanstalkd/go-beanstalk
tube.go
Stats
func (t *Tube) Stats() (map[string]string, error) { r, err := t.Conn.cmd(nil, nil, nil, "stats-tube", t.Name) if err != nil { return nil, err } body, err := t.Conn.readResp(r, true, "OK") return parseDict(body), err }
go
func (t *Tube) Stats() (map[string]string, error) { r, err := t.Conn.cmd(nil, nil, nil, "stats-tube", t.Name) if err != nil { return nil, err } body, err := t.Conn.readResp(r, true, "OK") return parseDict(body), err }
[ "func", "(", "t", "*", "Tube", ")", "Stats", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "r", ",", "err", ":=", "t", ".", "Conn", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ",", "t", "...
// Stats retrieves statistics about tube t.
[ "Stats", "retrieves", "statistics", "about", "tube", "t", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tube.go#L87-L94
143,221
beanstalkd/go-beanstalk
tube.go
Pause
func (t *Tube) Pause(d time.Duration) error { r, err := t.Conn.cmd(nil, nil, nil, "pause-tube", t.Name, dur(d)) if err != nil { return err } _, err = t.Conn.readResp(r, false, "PAUSED") if err != nil { return err } return nil }
go
func (t *Tube) Pause(d time.Duration) error { r, err := t.Conn.cmd(nil, nil, nil, "pause-tube", t.Name, dur(d)) if err != nil { return err } _, err = t.Conn.readResp(r, false, "PAUSED") if err != nil { return err } return nil }
[ "func", "(", "t", "*", "Tube", ")", "Pause", "(", "d", "time", ".", "Duration", ")", "error", "{", "r", ",", "err", ":=", "t", ".", "Conn", ".", "cmd", "(", "nil", ",", "nil", ",", "nil", ",", "\"", "\"", ",", "t", ".", "Name", ",", "dur", ...
// Pause pauses new reservations in t for time d.
[ "Pause", "pauses", "new", "reservations", "in", "t", "for", "time", "d", "." ]
7a112881e6c4f85f0d98f8929536e775d31fb4de
https://github.com/beanstalkd/go-beanstalk/blob/7a112881e6c4f85f0d98f8929536e775d31fb4de/tube.go#L97-L107
143,222
hashicorp/go-immutable-radix
iradix.go
Txn
func (t *Tree) Txn() *Txn { txn := &Txn{ root: t.root, snap: t.root, size: t.size, } return txn }
go
func (t *Tree) Txn() *Txn { txn := &Txn{ root: t.root, snap: t.root, size: t.size, } return txn }
[ "func", "(", "t", "*", "Tree", ")", "Txn", "(", ")", "*", "Txn", "{", "txn", ":=", "&", "Txn", "{", "root", ":", "t", ".", "root", ",", "snap", ":", "t", ".", "root", ",", "size", ":", "t", ".", "size", ",", "}", "\n", "return", "txn", "\...
// Txn starts a new transaction that can be used to mutate the tree
[ "Txn", "starts", "a", "new", "transaction", "that", "can", "be", "used", "to", "mutate", "the", "tree" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L80-L87
143,223
hashicorp/go-immutable-radix
iradix.go
trackChannel
func (t *Txn) trackChannel(ch chan struct{}) { // In overflow, make sure we don't store any more objects. if t.trackOverflow { return } // If this would overflow the state we reject it and set the flag (since // we aren't tracking everything that's required any longer). if len(t.trackChannels) >= defaultModifi...
go
func (t *Txn) trackChannel(ch chan struct{}) { // In overflow, make sure we don't store any more objects. if t.trackOverflow { return } // If this would overflow the state we reject it and set the flag (since // we aren't tracking everything that's required any longer). if len(t.trackChannels) >= defaultModifi...
[ "func", "(", "t", "*", "Txn", ")", "trackChannel", "(", "ch", "chan", "struct", "{", "}", ")", "{", "// In overflow, make sure we don't store any more objects.", "if", "t", ".", "trackOverflow", "{", "return", "\n", "}", "\n\n", "// If this would overflow the state ...
// trackChannel safely attempts to track the given mutation channel, setting the // overflow flag if we can no longer track any more. This limits the amount of // state that will accumulate during a transaction and we have a slower algorithm // to switch to if we overflow.
[ "trackChannel", "safely", "attempts", "to", "track", "the", "given", "mutation", "channel", "setting", "the", "overflow", "flag", "if", "we", "can", "no", "longer", "track", "any", "more", ".", "This", "limits", "the", "amount", "of", "state", "that", "will"...
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L100-L126
143,224
hashicorp/go-immutable-radix
iradix.go
writeNode
func (t *Txn) writeNode(n *Node, forLeafUpdate bool) *Node { // Ensure the writable set exists. if t.writable == nil { lru, err := simplelru.NewLRU(defaultModifiedCache, nil) if err != nil { panic(err) } t.writable = lru } // If this node has already been modified, we can continue to use it // during t...
go
func (t *Txn) writeNode(n *Node, forLeafUpdate bool) *Node { // Ensure the writable set exists. if t.writable == nil { lru, err := simplelru.NewLRU(defaultModifiedCache, nil) if err != nil { panic(err) } t.writable = lru } // If this node has already been modified, we can continue to use it // during t...
[ "func", "(", "t", "*", "Txn", ")", "writeNode", "(", "n", "*", "Node", ",", "forLeafUpdate", "bool", ")", "*", "Node", "{", "// Ensure the writable set exists.", "if", "t", ".", "writable", "==", "nil", "{", "lru", ",", "err", ":=", "simplelru", ".", "...
// writeNode returns a node to be modified, if the current node has already been // modified during the course of the transaction, it is used in-place. Set // forLeafUpdate to true if you are getting a write node to update the leaf, // which will set leaf mutation tracking appropriately as well.
[ "writeNode", "returns", "a", "node", "to", "be", "modified", "if", "the", "current", "node", "has", "already", "been", "modified", "during", "the", "course", "of", "the", "transaction", "it", "is", "used", "in", "-", "place", ".", "Set", "forLeafUpdate", "...
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L132-L184
143,225
hashicorp/go-immutable-radix
iradix.go
trackChannelsAndCount
func (t *Txn) trackChannelsAndCount(n *Node) int { // Count only leaf nodes leaves := 0 if n.leaf != nil { leaves = 1 } // Mark this node as being mutated. if t.trackMutate { t.trackChannel(n.mutateCh) } // Mark its leaf as being mutated, if appropriate. if t.trackMutate && n.leaf != nil { t.trackChanne...
go
func (t *Txn) trackChannelsAndCount(n *Node) int { // Count only leaf nodes leaves := 0 if n.leaf != nil { leaves = 1 } // Mark this node as being mutated. if t.trackMutate { t.trackChannel(n.mutateCh) } // Mark its leaf as being mutated, if appropriate. if t.trackMutate && n.leaf != nil { t.trackChanne...
[ "func", "(", "t", "*", "Txn", ")", "trackChannelsAndCount", "(", "n", "*", "Node", ")", "int", "{", "// Count only leaf nodes", "leaves", ":=", "0", "\n", "if", "n", ".", "leaf", "!=", "nil", "{", "leaves", "=", "1", "\n", "}", "\n", "// Mark this node...
// Visit all the nodes in the tree under n, and add their mutateChannels to the transaction // Returns the size of the subtree visited
[ "Visit", "all", "the", "nodes", "in", "the", "tree", "under", "n", "and", "add", "their", "mutateChannels", "to", "the", "transaction", "Returns", "the", "size", "of", "the", "subtree", "visited" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L188-L209
143,226
hashicorp/go-immutable-radix
iradix.go
mergeChild
func (t *Txn) mergeChild(n *Node) { // Mark the child node as being mutated since we are about to abandon // it. We don't need to mark the leaf since we are retaining it if it // is there. e := n.edges[0] child := e.node if t.trackMutate { t.trackChannel(child.mutateCh) } // Merge the nodes. n.prefix = conc...
go
func (t *Txn) mergeChild(n *Node) { // Mark the child node as being mutated since we are about to abandon // it. We don't need to mark the leaf since we are retaining it if it // is there. e := n.edges[0] child := e.node if t.trackMutate { t.trackChannel(child.mutateCh) } // Merge the nodes. n.prefix = conc...
[ "func", "(", "t", "*", "Txn", ")", "mergeChild", "(", "n", "*", "Node", ")", "{", "// Mark the child node as being mutated since we are about to abandon", "// it. We don't need to mark the leaf since we are retaining it if it", "// is there.", "e", ":=", "n", ".", "edges", ...
// mergeChild is called to collapse the given node with its child. This is only // called when the given node is not a leaf and has a single edge.
[ "mergeChild", "is", "called", "to", "collapse", "the", "given", "node", "with", "its", "child", ".", "This", "is", "only", "called", "when", "the", "given", "node", "is", "not", "a", "leaf", "and", "has", "a", "single", "edge", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L213-L232
143,227
hashicorp/go-immutable-radix
iradix.go
delete
func (t *Txn) delete(parent, n *Node, search []byte) (*Node, *leafNode) { // Check for key exhaustion if len(search) == 0 { if !n.isLeaf() { return nil, nil } // Copy the pointer in case we are in a transaction that already // modified this node since the node will be reused. Any changes // made to the n...
go
func (t *Txn) delete(parent, n *Node, search []byte) (*Node, *leafNode) { // Check for key exhaustion if len(search) == 0 { if !n.isLeaf() { return nil, nil } // Copy the pointer in case we are in a transaction that already // modified this node since the node will be reused. Any changes // made to the n...
[ "func", "(", "t", "*", "Txn", ")", "delete", "(", "parent", ",", "n", "*", "Node", ",", "search", "[", "]", "byte", ")", "(", "*", "Node", ",", "*", "leafNode", ")", "{", "// Check for key exhaustion", "if", "len", "(", "search", ")", "==", "0", ...
// delete does a recursive deletion
[ "delete", "does", "a", "recursive", "deletion" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L335-L388
143,228
hashicorp/go-immutable-radix
iradix.go
Insert
func (t *Txn) Insert(k []byte, v interface{}) (interface{}, bool) { newRoot, oldVal, didUpdate := t.insert(t.root, k, k, v) if newRoot != nil { t.root = newRoot } if !didUpdate { t.size++ } return oldVal, didUpdate }
go
func (t *Txn) Insert(k []byte, v interface{}) (interface{}, bool) { newRoot, oldVal, didUpdate := t.insert(t.root, k, k, v) if newRoot != nil { t.root = newRoot } if !didUpdate { t.size++ } return oldVal, didUpdate }
[ "func", "(", "t", "*", "Txn", ")", "Insert", "(", "k", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "newRoot", ",", "oldVal", ",", "didUpdate", ":=", "t", ".", "insert", "(", "t", ...
// Insert is used to add or update a given key. The return provides // the previous value and a bool indicating if any was set.
[ "Insert", "is", "used", "to", "add", "or", "update", "a", "given", "key", ".", "The", "return", "provides", "the", "previous", "value", "and", "a", "bool", "indicating", "if", "any", "was", "set", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L442-L451
143,229
hashicorp/go-immutable-radix
iradix.go
Delete
func (t *Txn) Delete(k []byte) (interface{}, bool) { newRoot, leaf := t.delete(nil, t.root, k) if newRoot != nil { t.root = newRoot } if leaf != nil { t.size-- return leaf.val, true } return nil, false }
go
func (t *Txn) Delete(k []byte) (interface{}, bool) { newRoot, leaf := t.delete(nil, t.root, k) if newRoot != nil { t.root = newRoot } if leaf != nil { t.size-- return leaf.val, true } return nil, false }
[ "func", "(", "t", "*", "Txn", ")", "Delete", "(", "k", "[", "]", "byte", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "newRoot", ",", "leaf", ":=", "t", ".", "delete", "(", "nil", ",", "t", ".", "root", ",", "k", ")", "\n", "if",...
// Delete is used to delete a given key. Returns the old value if any, // and a bool indicating if the key was set.
[ "Delete", "is", "used", "to", "delete", "a", "given", "key", ".", "Returns", "the", "old", "value", "if", "any", "and", "a", "bool", "indicating", "if", "the", "key", "was", "set", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L455-L465
143,230
hashicorp/go-immutable-radix
iradix.go
DeletePrefix
func (t *Txn) DeletePrefix(prefix []byte) bool { newRoot, numDeletions := t.deletePrefix(nil, t.root, prefix) if newRoot != nil { t.root = newRoot t.size = t.size - numDeletions return true } return false }
go
func (t *Txn) DeletePrefix(prefix []byte) bool { newRoot, numDeletions := t.deletePrefix(nil, t.root, prefix) if newRoot != nil { t.root = newRoot t.size = t.size - numDeletions return true } return false }
[ "func", "(", "t", "*", "Txn", ")", "DeletePrefix", "(", "prefix", "[", "]", "byte", ")", "bool", "{", "newRoot", ",", "numDeletions", ":=", "t", ".", "deletePrefix", "(", "nil", ",", "t", ".", "root", ",", "prefix", ")", "\n", "if", "newRoot", "!="...
// DeletePrefix is used to delete an entire subtree that matches the prefix // This will delete all nodes under that prefix
[ "DeletePrefix", "is", "used", "to", "delete", "an", "entire", "subtree", "that", "matches", "the", "prefix", "This", "will", "delete", "all", "nodes", "under", "that", "prefix" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L469-L478
143,231
hashicorp/go-immutable-radix
iradix.go
GetWatch
func (t *Txn) GetWatch(k []byte) (<-chan struct{}, interface{}, bool) { return t.root.GetWatch(k) }
go
func (t *Txn) GetWatch(k []byte) (<-chan struct{}, interface{}, bool) { return t.root.GetWatch(k) }
[ "func", "(", "t", "*", "Txn", ")", "GetWatch", "(", "k", "[", "]", "byte", ")", "(", "<-", "chan", "struct", "{", "}", ",", "interface", "{", "}", ",", "bool", ")", "{", "return", "t", ".", "root", ".", "GetWatch", "(", "k", ")", "\n", "}" ]
// GetWatch is used to lookup a specific key, returning // the watch channel, value and if it was found
[ "GetWatch", "is", "used", "to", "lookup", "a", "specific", "key", "returning", "the", "watch", "channel", "value", "and", "if", "it", "was", "found" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L495-L497
143,232
hashicorp/go-immutable-radix
iradix.go
Commit
func (t *Txn) Commit() *Tree { nt := t.CommitOnly() if t.trackMutate { t.Notify() } return nt }
go
func (t *Txn) Commit() *Tree { nt := t.CommitOnly() if t.trackMutate { t.Notify() } return nt }
[ "func", "(", "t", "*", "Txn", ")", "Commit", "(", ")", "*", "Tree", "{", "nt", ":=", "t", ".", "CommitOnly", "(", ")", "\n", "if", "t", ".", "trackMutate", "{", "t", ".", "Notify", "(", ")", "\n", "}", "\n", "return", "nt", "\n", "}" ]
// Commit is used to finalize the transaction and return a new tree. If mutation // tracking is turned on then notifications will also be issued.
[ "Commit", "is", "used", "to", "finalize", "the", "transaction", "and", "return", "a", "new", "tree", ".", "If", "mutation", "tracking", "is", "turned", "on", "then", "notifications", "will", "also", "be", "issued", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L501-L507
143,233
hashicorp/go-immutable-radix
iradix.go
CommitOnly
func (t *Txn) CommitOnly() *Tree { nt := &Tree{t.root, t.size} t.writable = nil return nt }
go
func (t *Txn) CommitOnly() *Tree { nt := &Tree{t.root, t.size} t.writable = nil return nt }
[ "func", "(", "t", "*", "Txn", ")", "CommitOnly", "(", ")", "*", "Tree", "{", "nt", ":=", "&", "Tree", "{", "t", ".", "root", ",", "t", ".", "size", "}", "\n", "t", ".", "writable", "=", "nil", "\n", "return", "nt", "\n", "}" ]
// CommitOnly is used to finalize the transaction and return a new tree, but // does not issue any notifications until Notify is called.
[ "CommitOnly", "is", "used", "to", "finalize", "the", "transaction", "and", "return", "a", "new", "tree", "but", "does", "not", "issue", "any", "notifications", "until", "Notify", "is", "called", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L511-L515
143,234
hashicorp/go-immutable-radix
iradix.go
slowNotify
func (t *Txn) slowNotify() { snapIter := t.snap.rawIterator() rootIter := t.root.rawIterator() for snapIter.Front() != nil || rootIter.Front() != nil { // If we've exhausted the nodes in the old snapshot, we know // there's nothing remaining to notify. if snapIter.Front() == nil { return } snapElem := s...
go
func (t *Txn) slowNotify() { snapIter := t.snap.rawIterator() rootIter := t.root.rawIterator() for snapIter.Front() != nil || rootIter.Front() != nil { // If we've exhausted the nodes in the old snapshot, we know // there's nothing remaining to notify. if snapIter.Front() == nil { return } snapElem := s...
[ "func", "(", "t", "*", "Txn", ")", "slowNotify", "(", ")", "{", "snapIter", ":=", "t", ".", "snap", ".", "rawIterator", "(", ")", "\n", "rootIter", ":=", "t", ".", "root", ".", "rawIterator", "(", ")", "\n", "for", "snapIter", ".", "Front", "(", ...
// slowNotify does a complete comparison of the before and after trees in order // to trigger notifications. This doesn't require any additional state but it // is very expensive to compute.
[ "slowNotify", "does", "a", "complete", "comparison", "of", "the", "before", "and", "after", "trees", "in", "order", "to", "trigger", "notifications", ".", "This", "doesn", "t", "require", "any", "additional", "state", "but", "it", "is", "very", "expensive", ...
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L520-L578
143,235
hashicorp/go-immutable-radix
iradix.go
Notify
func (t *Txn) Notify() { if !t.trackMutate { return } // If we've overflowed the tracking state we can't use it in any way and // need to do a full tree compare. if t.trackOverflow { t.slowNotify() } else { for ch := range t.trackChannels { close(ch) } } // Clean up the tracking state so that a re-...
go
func (t *Txn) Notify() { if !t.trackMutate { return } // If we've overflowed the tracking state we can't use it in any way and // need to do a full tree compare. if t.trackOverflow { t.slowNotify() } else { for ch := range t.trackChannels { close(ch) } } // Clean up the tracking state so that a re-...
[ "func", "(", "t", "*", "Txn", ")", "Notify", "(", ")", "{", "if", "!", "t", ".", "trackMutate", "{", "return", "\n", "}", "\n\n", "// If we've overflowed the tracking state we can't use it in any way and", "// need to do a full tree compare.", "if", "t", ".", "track...
// Notify is used along with TrackMutate to trigger notifications. This must // only be done once a transaction is committed via CommitOnly, and it is called // automatically by Commit.
[ "Notify", "is", "used", "along", "with", "TrackMutate", "to", "trigger", "notifications", ".", "This", "must", "only", "be", "done", "once", "a", "transaction", "is", "committed", "via", "CommitOnly", "and", "it", "is", "called", "automatically", "by", "Commit...
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L583-L602
143,236
hashicorp/go-immutable-radix
iradix.go
Insert
func (t *Tree) Insert(k []byte, v interface{}) (*Tree, interface{}, bool) { txn := t.Txn() old, ok := txn.Insert(k, v) return txn.Commit(), old, ok }
go
func (t *Tree) Insert(k []byte, v interface{}) (*Tree, interface{}, bool) { txn := t.Txn() old, ok := txn.Insert(k, v) return txn.Commit(), old, ok }
[ "func", "(", "t", "*", "Tree", ")", "Insert", "(", "k", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "(", "*", "Tree", ",", "interface", "{", "}", ",", "bool", ")", "{", "txn", ":=", "t", ".", "Txn", "(", ")", "\n", "old", ",", ...
// Insert is used to add or update a given key. The return provides // the new tree, previous value and a bool indicating if any was set.
[ "Insert", "is", "used", "to", "add", "or", "update", "a", "given", "key", ".", "The", "return", "provides", "the", "new", "tree", "previous", "value", "and", "a", "bool", "indicating", "if", "any", "was", "set", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L606-L610
143,237
hashicorp/go-immutable-radix
iradix.go
Delete
func (t *Tree) Delete(k []byte) (*Tree, interface{}, bool) { txn := t.Txn() old, ok := txn.Delete(k) return txn.Commit(), old, ok }
go
func (t *Tree) Delete(k []byte) (*Tree, interface{}, bool) { txn := t.Txn() old, ok := txn.Delete(k) return txn.Commit(), old, ok }
[ "func", "(", "t", "*", "Tree", ")", "Delete", "(", "k", "[", "]", "byte", ")", "(", "*", "Tree", ",", "interface", "{", "}", ",", "bool", ")", "{", "txn", ":=", "t", ".", "Txn", "(", ")", "\n", "old", ",", "ok", ":=", "txn", ".", "Delete", ...
// Delete is used to delete a given key. Returns the new tree, // old value if any, and a bool indicating if the key was set.
[ "Delete", "is", "used", "to", "delete", "a", "given", "key", ".", "Returns", "the", "new", "tree", "old", "value", "if", "any", "and", "a", "bool", "indicating", "if", "the", "key", "was", "set", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L614-L618
143,238
hashicorp/go-immutable-radix
iradix.go
DeletePrefix
func (t *Tree) DeletePrefix(k []byte) (*Tree, bool) { txn := t.Txn() ok := txn.DeletePrefix(k) return txn.Commit(), ok }
go
func (t *Tree) DeletePrefix(k []byte) (*Tree, bool) { txn := t.Txn() ok := txn.DeletePrefix(k) return txn.Commit(), ok }
[ "func", "(", "t", "*", "Tree", ")", "DeletePrefix", "(", "k", "[", "]", "byte", ")", "(", "*", "Tree", ",", "bool", ")", "{", "txn", ":=", "t", ".", "Txn", "(", ")", "\n", "ok", ":=", "txn", ".", "DeletePrefix", "(", "k", ")", "\n", "return",...
// DeletePrefix is used to delete all nodes starting with a given prefix. Returns the new tree, // and a bool indicating if the prefix matched any nodes
[ "DeletePrefix", "is", "used", "to", "delete", "all", "nodes", "starting", "with", "a", "given", "prefix", ".", "Returns", "the", "new", "tree", "and", "a", "bool", "indicating", "if", "the", "prefix", "matched", "any", "nodes" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L622-L626
143,239
hashicorp/go-immutable-radix
iradix.go
longestPrefix
func longestPrefix(k1, k2 []byte) int { max := len(k1) if l := len(k2); l < max { max = l } var i int for i = 0; i < max; i++ { if k1[i] != k2[i] { break } } return i }
go
func longestPrefix(k1, k2 []byte) int { max := len(k1) if l := len(k2); l < max { max = l } var i int for i = 0; i < max; i++ { if k1[i] != k2[i] { break } } return i }
[ "func", "longestPrefix", "(", "k1", ",", "k2", "[", "]", "byte", ")", "int", "{", "max", ":=", "len", "(", "k1", ")", "\n", "if", "l", ":=", "len", "(", "k2", ")", ";", "l", "<", "max", "{", "max", "=", "l", "\n", "}", "\n", "var", "i", "...
// longestPrefix finds the length of the shared prefix // of two strings
[ "longestPrefix", "finds", "the", "length", "of", "the", "shared", "prefix", "of", "two", "strings" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L642-L654
143,240
hashicorp/go-immutable-radix
iradix.go
concat
func concat(a, b []byte) []byte { c := make([]byte, len(a)+len(b)) copy(c, a) copy(c[len(a):], b) return c }
go
func concat(a, b []byte) []byte { c := make([]byte, len(a)+len(b)) copy(c, a) copy(c[len(a):], b) return c }
[ "func", "concat", "(", "a", ",", "b", "[", "]", "byte", ")", "[", "]", "byte", "{", "c", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "a", ")", "+", "len", "(", "b", ")", ")", "\n", "copy", "(", "c", ",", "a", ")", "\n", "copy"...
// concat two byte slices, returning a third new copy
[ "concat", "two", "byte", "slices", "returning", "a", "third", "new", "copy" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iradix.go#L657-L662
143,241
hashicorp/go-immutable-radix
node.go
LongestPrefix
func (n *Node) LongestPrefix(k []byte) ([]byte, interface{}, bool) { var last *leafNode search := k for { // Look for a leaf node if n.isLeaf() { last = n.leaf } // Check for key exhaution if len(search) == 0 { break } // Look for an edge _, n = n.getEdge(search[0]) if n == nil { break ...
go
func (n *Node) LongestPrefix(k []byte) ([]byte, interface{}, bool) { var last *leafNode search := k for { // Look for a leaf node if n.isLeaf() { last = n.leaf } // Check for key exhaution if len(search) == 0 { break } // Look for an edge _, n = n.getEdge(search[0]) if n == nil { break ...
[ "func", "(", "n", "*", "Node", ")", "LongestPrefix", "(", "k", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "interface", "{", "}", ",", "bool", ")", "{", "var", "last", "*", "leafNode", "\n", "search", ":=", "k", "\n", "for", "{", "// Loo...
// LongestPrefix is like Get, but instead of an // exact match, it will return the longest prefix match.
[ "LongestPrefix", "is", "like", "Get", "but", "instead", "of", "an", "exact", "match", "it", "will", "return", "the", "longest", "prefix", "match", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/node.go#L132-L163
143,242
hashicorp/go-immutable-radix
node.go
Minimum
func (n *Node) Minimum() ([]byte, interface{}, bool) { for { if n.isLeaf() { return n.leaf.key, n.leaf.val, true } if len(n.edges) > 0 { n = n.edges[0].node } else { break } } return nil, nil, false }
go
func (n *Node) Minimum() ([]byte, interface{}, bool) { for { if n.isLeaf() { return n.leaf.key, n.leaf.val, true } if len(n.edges) > 0 { n = n.edges[0].node } else { break } } return nil, nil, false }
[ "func", "(", "n", "*", "Node", ")", "Minimum", "(", ")", "(", "[", "]", "byte", ",", "interface", "{", "}", ",", "bool", ")", "{", "for", "{", "if", "n", ".", "isLeaf", "(", ")", "{", "return", "n", ".", "leaf", ".", "key", ",", "n", ".", ...
// Minimum is used to return the minimum value in the tree
[ "Minimum", "is", "used", "to", "return", "the", "minimum", "value", "in", "the", "tree" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/node.go#L166-L178
143,243
hashicorp/go-immutable-radix
node.go
rawIterator
func (n *Node) rawIterator() *rawIterator { iter := &rawIterator{node: n} iter.Next() return iter }
go
func (n *Node) rawIterator() *rawIterator { iter := &rawIterator{node: n} iter.Next() return iter }
[ "func", "(", "n", "*", "Node", ")", "rawIterator", "(", ")", "*", "rawIterator", "{", "iter", ":=", "&", "rawIterator", "{", "node", ":", "n", "}", "\n", "iter", ".", "Next", "(", ")", "\n", "return", "iter", "\n", "}" ]
// rawIterator is used to return a raw iterator at the given node to walk the // tree.
[ "rawIterator", "is", "used", "to", "return", "a", "raw", "iterator", "at", "the", "given", "node", "to", "walk", "the", "tree", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/node.go#L204-L208
143,244
hashicorp/go-immutable-radix
node.go
WalkPrefix
func (n *Node) WalkPrefix(prefix []byte, fn WalkFn) { search := prefix for { // Check for key exhaution if len(search) == 0 { recursiveWalk(n, fn) return } // Look for an edge _, n = n.getEdge(search[0]) if n == nil { break } // Consume the search prefix if bytes.HasPrefix(search, n.prefi...
go
func (n *Node) WalkPrefix(prefix []byte, fn WalkFn) { search := prefix for { // Check for key exhaution if len(search) == 0 { recursiveWalk(n, fn) return } // Look for an edge _, n = n.getEdge(search[0]) if n == nil { break } // Consume the search prefix if bytes.HasPrefix(search, n.prefi...
[ "func", "(", "n", "*", "Node", ")", "WalkPrefix", "(", "prefix", "[", "]", "byte", ",", "fn", "WalkFn", ")", "{", "search", ":=", "prefix", "\n", "for", "{", "// Check for key exhaution", "if", "len", "(", "search", ")", "==", "0", "{", "recursiveWalk"...
// WalkPrefix is used to walk the tree under a prefix
[ "WalkPrefix", "is", "used", "to", "walk", "the", "tree", "under", "a", "prefix" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/node.go#L216-L243
143,245
hashicorp/go-immutable-radix
iter.go
SeekPrefixWatch
func (i *Iterator) SeekPrefixWatch(prefix []byte) (watch <-chan struct{}) { // Wipe the stack i.stack = nil n := i.node watch = n.mutateCh search := prefix for { // Check for key exhaution if len(search) == 0 { i.node = n return } // Look for an edge _, n = n.getEdge(search[0]) if n == nil { ...
go
func (i *Iterator) SeekPrefixWatch(prefix []byte) (watch <-chan struct{}) { // Wipe the stack i.stack = nil n := i.node watch = n.mutateCh search := prefix for { // Check for key exhaution if len(search) == 0 { i.node = n return } // Look for an edge _, n = n.getEdge(search[0]) if n == nil { ...
[ "func", "(", "i", "*", "Iterator", ")", "SeekPrefixWatch", "(", "prefix", "[", "]", "byte", ")", "(", "watch", "<-", "chan", "struct", "{", "}", ")", "{", "// Wipe the stack", "i", ".", "stack", "=", "nil", "\n", "n", ":=", "i", ".", "node", "\n", ...
// SeekPrefixWatch is used to seek the iterator to a given prefix // and returns the watch channel of the finest granularity
[ "SeekPrefixWatch", "is", "used", "to", "seek", "the", "iterator", "to", "a", "given", "prefix", "and", "returns", "the", "watch", "channel", "of", "the", "finest", "granularity" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iter.go#L14-L49
143,246
hashicorp/go-immutable-radix
iter.go
Next
func (i *Iterator) Next() ([]byte, interface{}, bool) { // Initialize our stack if needed if i.stack == nil && i.node != nil { i.stack = []edges{ edges{ edge{node: i.node}, }, } } for len(i.stack) > 0 { // Inspect the last element of the stack n := len(i.stack) last := i.stack[n-1] elem := la...
go
func (i *Iterator) Next() ([]byte, interface{}, bool) { // Initialize our stack if needed if i.stack == nil && i.node != nil { i.stack = []edges{ edges{ edge{node: i.node}, }, } } for len(i.stack) > 0 { // Inspect the last element of the stack n := len(i.stack) last := i.stack[n-1] elem := la...
[ "func", "(", "i", "*", "Iterator", ")", "Next", "(", ")", "(", "[", "]", "byte", ",", "interface", "{", "}", ",", "bool", ")", "{", "// Initialize our stack if needed", "if", "i", ".", "stack", "==", "nil", "&&", "i", ".", "node", "!=", "nil", "{",...
// Next returns the next node in order
[ "Next", "returns", "the", "next", "node", "in", "order" ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/iter.go#L57-L91
143,247
hashicorp/go-immutable-radix
raw_iter.go
Next
func (i *rawIterator) Next() { // Initialize our stack if needed. if i.stack == nil && i.node != nil { i.stack = []rawStackEntry{ rawStackEntry{ edges: edges{ edge{node: i.node}, }, }, } } for len(i.stack) > 0 { // Inspect the last element of the stack. n := len(i.stack) last := i.stac...
go
func (i *rawIterator) Next() { // Initialize our stack if needed. if i.stack == nil && i.node != nil { i.stack = []rawStackEntry{ rawStackEntry{ edges: edges{ edge{node: i.node}, }, }, } } for len(i.stack) > 0 { // Inspect the last element of the stack. n := len(i.stack) last := i.stac...
[ "func", "(", "i", "*", "rawIterator", ")", "Next", "(", ")", "{", "// Initialize our stack if needed.", "if", "i", ".", "stack", "==", "nil", "&&", "i", ".", "node", "!=", "nil", "{", "i", ".", "stack", "=", "[", "]", "rawStackEntry", "{", "rawStackEnt...
// Next advances the iterator to the next node.
[ "Next", "advances", "the", "iterator", "to", "the", "next", "node", "." ]
27df80928bb34bb1b0d6d0e01b9e679902e7a6b5
https://github.com/hashicorp/go-immutable-radix/blob/27df80928bb34bb1b0d6d0e01b9e679902e7a6b5/raw_iter.go#L40-L78
143,248
lestrrat-go/jwx
jwe/serializer.go
Serialize
func (s CompactSerialize) Serialize(m *Message) ([]byte, error) { if len(m.Recipients) != 1 { return nil, errors.New("wrong number of recipients for compact serialization") } recipient := m.Recipients[0] // The protected header must be a merge between the message-wide // protected header AND the recipient head...
go
func (s CompactSerialize) Serialize(m *Message) ([]byte, error) { if len(m.Recipients) != 1 { return nil, errors.New("wrong number of recipients for compact serialization") } recipient := m.Recipients[0] // The protected header must be a merge between the message-wide // protected header AND the recipient head...
[ "func", "(", "s", "CompactSerialize", ")", "Serialize", "(", "m", "*", "Message", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "m", ".", "Recipients", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "New", "(", ...
// Serialize converts the message into a JWE compact serialize format byte buffer
[ "Serialize", "converts", "the", "message", "into", "a", "JWE", "compact", "serialize", "format", "byte", "buffer" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/serializer.go#L10-L65
143,249
lestrrat-go/jwx
jwe/serializer.go
Serialize
func (s JSONSerialize) Serialize(m *Message) ([]byte, error) { if s.Pretty { return json.MarshalIndent(m, "", " ") } return json.Marshal(m) }
go
func (s JSONSerialize) Serialize(m *Message) ([]byte, error) { if s.Pretty { return json.MarshalIndent(m, "", " ") } return json.Marshal(m) }
[ "func", "(", "s", "JSONSerialize", ")", "Serialize", "(", "m", "*", "Message", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "s", ".", "Pretty", "{", "return", "json", ".", "MarshalIndent", "(", "m", ",", "\"", "\"", ",", "\"", "\"", ...
// Serialize converts the message into a JWE JSON serialize format byte buffer
[ "Serialize", "converts", "the", "message", "into", "a", "JWE", "JSON", "serialize", "format", "byte", "buffer" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/serializer.go#L68-L73
143,250
lestrrat-go/jwx
jwe/aescbc/aescbc.go
Seal
func (c AesCbcHmac) Seal(dst, nonce, plaintext, data []byte) []byte { ctlen := len(plaintext) ciphertext := make([]byte, ctlen+c.Overhead())[:ctlen] copy(ciphertext, plaintext) ciphertext = padbuf.PadBuffer(ciphertext).Pad(c.blockCipher.BlockSize()) cbc := cipher.NewCBCEncrypter(c.blockCipher, nonce) cbc.CryptBl...
go
func (c AesCbcHmac) Seal(dst, nonce, plaintext, data []byte) []byte { ctlen := len(plaintext) ciphertext := make([]byte, ctlen+c.Overhead())[:ctlen] copy(ciphertext, plaintext) ciphertext = padbuf.PadBuffer(ciphertext).Pad(c.blockCipher.BlockSize()) cbc := cipher.NewCBCEncrypter(c.blockCipher, nonce) cbc.CryptBl...
[ "func", "(", "c", "AesCbcHmac", ")", "Seal", "(", "dst", ",", "nonce", ",", "plaintext", ",", "data", "[", "]", "byte", ")", "[", "]", "byte", "{", "ctlen", ":=", "len", "(", "plaintext", ")", "\n", "ciphertext", ":=", "make", "(", "[", "]", "byt...
// Seal fulfills the crypto.AEAD interface
[ "Seal", "fulfills", "the", "crypto", ".", "AEAD", "interface" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/aescbc/aescbc.go#L119-L143
143,251
lestrrat-go/jwx
jwe/aescbc/aescbc.go
Open
func (c AesCbcHmac) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) { if len(ciphertext) < c.keysize { return nil, errors.New("invalid ciphertext (too short)") } tagOffset := len(ciphertext) - c.tagsize if tagOffset%c.blockCipher.BlockSize() != 0 { return nil, fmt.Errorf( "invalid ciphertext (inva...
go
func (c AesCbcHmac) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) { if len(ciphertext) < c.keysize { return nil, errors.New("invalid ciphertext (too short)") } tagOffset := len(ciphertext) - c.tagsize if tagOffset%c.blockCipher.BlockSize() != 0 { return nil, fmt.Errorf( "invalid ciphertext (inva...
[ "func", "(", "c", "AesCbcHmac", ")", "Open", "(", "dst", ",", "nonce", ",", "ciphertext", ",", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "ciphertext", ")", "<", "c", ".", "keysize", "{", "re...
// Open fulfills the crypto.AEAD interface
[ "Open", "fulfills", "the", "crypto", ".", "AEAD", "interface" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/aescbc/aescbc.go#L146-L183
143,252
lestrrat-go/jwx
jwk/headers_gen.go
PopulateMap
func (h StandardHeaders) PopulateMap(m map[string]interface{}) error { for k, v := range h.privateParams { m[k] = v } if v, ok := h.Get(AlgorithmKey); ok { m[AlgorithmKey] = v } if v, ok := h.Get(KeyIDKey); ok { m[KeyIDKey] = v } if v, ok := h.Get(KeyTypeKey); ok { m[KeyTypeKey] = v } if v, ok := h.Get...
go
func (h StandardHeaders) PopulateMap(m map[string]interface{}) error { for k, v := range h.privateParams { m[k] = v } if v, ok := h.Get(AlgorithmKey); ok { m[AlgorithmKey] = v } if v, ok := h.Get(KeyIDKey); ok { m[KeyIDKey] = v } if v, ok := h.Get(KeyTypeKey); ok { m[KeyTypeKey] = v } if v, ok := h.Get...
[ "func", "(", "h", "StandardHeaders", ")", "PopulateMap", "(", "m", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "for", "k", ",", "v", ":=", "range", "h", ".", "privateParams", "{", "m", "[", "k", "]", "=", "v", "\n", "}", ...
// PopulateMap populates a map with appropriate values that represent // the headers as a JSON object. This exists primarily because JWKs are // represented as flat objects instead of differentiating the different // parts of the message in separate sub objects.
[ "PopulateMap", "populates", "a", "map", "with", "appropriate", "values", "that", "represent", "the", "headers", "as", "a", "JSON", "object", ".", "This", "exists", "primarily", "because", "JWKs", "are", "represented", "as", "flat", "objects", "instead", "of", ...
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwk/headers_gen.go#L254-L287
143,253
lestrrat-go/jwx
jwe/encrypt.go
NewMultiEncrypt
func NewMultiEncrypt(cc ContentEncrypter, kg KeyGenerator, ke ...KeyEncrypter) *MultiEncrypt { e := &MultiEncrypt{ ContentEncrypter: cc, KeyGenerator: kg, KeyEncrypters: ke, } return e }
go
func NewMultiEncrypt(cc ContentEncrypter, kg KeyGenerator, ke ...KeyEncrypter) *MultiEncrypt { e := &MultiEncrypt{ ContentEncrypter: cc, KeyGenerator: kg, KeyEncrypters: ke, } return e }
[ "func", "NewMultiEncrypt", "(", "cc", "ContentEncrypter", ",", "kg", "KeyGenerator", ",", "ke", "...", "KeyEncrypter", ")", "*", "MultiEncrypt", "{", "e", ":=", "&", "MultiEncrypt", "{", "ContentEncrypter", ":", "cc", ",", "KeyGenerator", ":", "kg", ",", "Ke...
// NewMultiEncrypt creates a new Encrypt struct. The caller is responsible // for instantiating valid inputs for ContentEncrypter, KeyGenerator, // and KeyEncrypters.
[ "NewMultiEncrypt", "creates", "a", "new", "Encrypt", "struct", ".", "The", "caller", "is", "responsible", "for", "instantiating", "valid", "inputs", "for", "ContentEncrypter", "KeyGenerator", "and", "KeyEncrypters", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/encrypt.go#L11-L18
143,254
lestrrat-go/jwx
jwe/jwe.go
Decrypt
func Decrypt(buf []byte, alg jwa.KeyEncryptionAlgorithm, key interface{}) ([]byte, error) { msg, err := Parse(buf) if err != nil { return nil, errors.Wrap(err, "failed to parse buffer for Decrypt") } return msg.Decrypt(alg, key) }
go
func Decrypt(buf []byte, alg jwa.KeyEncryptionAlgorithm, key interface{}) ([]byte, error) { msg, err := Parse(buf) if err != nil { return nil, errors.Wrap(err, "failed to parse buffer for Decrypt") } return msg.Decrypt(alg, key) }
[ "func", "Decrypt", "(", "buf", "[", "]", "byte", ",", "alg", "jwa", ".", "KeyEncryptionAlgorithm", ",", "key", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "msg", ",", "err", ":=", "Parse", "(", "buf", ")", "\n", "if...
// Decrypt takes the key encryption algorithm and the corresponding // key to decrypt the JWE message, and returns the decrypted payload. // The JWE message can be either compact or full JSON format.
[ "Decrypt", "takes", "the", "key", "encryption", "algorithm", "and", "the", "corresponding", "key", "to", "decrypt", "the", "JWE", "message", "and", "returns", "the", "decrypted", "payload", ".", "The", "JWE", "message", "can", "be", "either", "compact", "or", ...
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/jwe.go#L103-L110
143,255
lestrrat-go/jwx
jwe/jwe.go
Parse
func Parse(buf []byte) (*Message, error) { buf = bytes.TrimSpace(buf) if len(buf) == 0 { return nil, errors.New("empty buffer") } if buf[0] == '{' { return parseJSON(buf) } return parseCompact(buf) }
go
func Parse(buf []byte) (*Message, error) { buf = bytes.TrimSpace(buf) if len(buf) == 0 { return nil, errors.New("empty buffer") } if buf[0] == '{' { return parseJSON(buf) } return parseCompact(buf) }
[ "func", "Parse", "(", "buf", "[", "]", "byte", ")", "(", "*", "Message", ",", "error", ")", "{", "buf", "=", "bytes", ".", "TrimSpace", "(", "buf", ")", "\n", "if", "len", "(", "buf", ")", "==", "0", "{", "return", "nil", ",", "errors", ".", ...
// Parse parses the JWE message into a Message object. The JWE message // can be either compact or full JSON format.
[ "Parse", "parses", "the", "JWE", "message", "into", "a", "Message", "object", ".", "The", "JWE", "message", "can", "be", "either", "compact", "or", "full", "JSON", "format", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/jwe.go#L114-L124
143,256
lestrrat-go/jwx
jwk/jwk.go
New
func New(key interface{}) (Key, error) { if key == nil { return nil, errors.New(`jwk.New requires a non-nil key`) } switch v := key.(type) { case *rsa.PrivateKey: return newRSAPrivateKey(v) case *rsa.PublicKey: return newRSAPublicKey(v) case *ecdsa.PrivateKey: return newECDSAPrivateKey(v) case *ecdsa.Pu...
go
func New(key interface{}) (Key, error) { if key == nil { return nil, errors.New(`jwk.New requires a non-nil key`) } switch v := key.(type) { case *rsa.PrivateKey: return newRSAPrivateKey(v) case *rsa.PublicKey: return newRSAPublicKey(v) case *ecdsa.PrivateKey: return newECDSAPrivateKey(v) case *ecdsa.Pu...
[ "func", "New", "(", "key", "interface", "{", "}", ")", "(", "Key", ",", "error", ")", "{", "if", "key", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "`jwk.New requires a non-nil key`", ")", "\n", "}", "\n\n", "switch", "v", ":="...
// New creates a jwk.Key from the given key.
[ "New", "creates", "a", "jwk", ".", "Key", "from", "the", "given", "key", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwk/jwk.go#L49-L68
143,257
lestrrat-go/jwx
jwk/jwk.go
Fetch
func Fetch(urlstring string, options ...Option) (*Set, error) { u, err := url.Parse(urlstring) if err != nil { return nil, errors.Wrap(err, `failed to parse url`) } switch u.Scheme { case "http", "https": return FetchHTTP(urlstring, options...) case "file": f, err := os.Open(u.Path) if err != nil { re...
go
func Fetch(urlstring string, options ...Option) (*Set, error) { u, err := url.Parse(urlstring) if err != nil { return nil, errors.Wrap(err, `failed to parse url`) } switch u.Scheme { case "http", "https": return FetchHTTP(urlstring, options...) case "file": f, err := os.Open(u.Path) if err != nil { re...
[ "func", "Fetch", "(", "urlstring", "string", ",", "options", "...", "Option", ")", "(", "*", "Set", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "urlstring", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "...
// Fetch fetches a JWK resource specified by a URL
[ "Fetch", "fetches", "a", "JWK", "resource", "specified", "by", "a", "URL" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwk/jwk.go#L71-L94
143,258
lestrrat-go/jwx
jwk/jwk.go
FetchHTTP
func FetchHTTP(jwkurl string, options ...Option) (*Set, error) { var httpcl HTTPClient = http.DefaultClient for _, option := range options { switch option.Name() { case optkeyHTTPClient: httpcl = option.Value().(HTTPClient) } } res, err := httpcl.Get(jwkurl) if err != nil { return nil, errors.Wrap(err,...
go
func FetchHTTP(jwkurl string, options ...Option) (*Set, error) { var httpcl HTTPClient = http.DefaultClient for _, option := range options { switch option.Name() { case optkeyHTTPClient: httpcl = option.Value().(HTTPClient) } } res, err := httpcl.Get(jwkurl) if err != nil { return nil, errors.Wrap(err,...
[ "func", "FetchHTTP", "(", "jwkurl", "string", ",", "options", "...", "Option", ")", "(", "*", "Set", ",", "error", ")", "{", "var", "httpcl", "HTTPClient", "=", "http", ".", "DefaultClient", "\n", "for", "_", ",", "option", ":=", "range", "options", "{...
// FetchHTTP fetches the remote JWK and parses its contents
[ "FetchHTTP", "fetches", "the", "remote", "JWK", "and", "parses", "its", "contents" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwk/jwk.go#L97-L122
143,259
lestrrat-go/jwx
jwk/jwk.go
Parse
func Parse(in io.Reader) (*Set, error) { m := make(map[string]interface{}) if err := json.NewDecoder(in).Decode(&m); err != nil { return nil, errors.Wrap(err, "failed to unmarshal JWK") } // We must change what the underlying structure that gets decoded // out of this JSON is based on parameters within the alre...
go
func Parse(in io.Reader) (*Set, error) { m := make(map[string]interface{}) if err := json.NewDecoder(in).Decode(&m); err != nil { return nil, errors.Wrap(err, "failed to unmarshal JWK") } // We must change what the underlying structure that gets decoded // out of this JSON is based on parameters within the alre...
[ "func", "Parse", "(", "in", "io", ".", "Reader", ")", "(", "*", "Set", ",", "error", ")", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "err", ":=", "json", ".", "NewDecoder", "(", "in", ")", ...
// Parse parses JWK from the incoming io.Reader.
[ "Parse", "parses", "JWK", "from", "the", "incoming", "io", ".", "Reader", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwk/jwk.go#L134-L157
143,260
lestrrat-go/jwx
jws/message.go
LookupSignature
func (m Message) LookupSignature(kid string) []*Signature { var sigs []*Signature for _, sig := range m.signatures { if hdr := sig.PublicHeaders(); hdr != nil { hdrKeyId, ok := hdr.Get(KeyIDKey) if ok && hdrKeyId == kid { sigs = append(sigs, sig) continue } } if hdr := sig.ProtectedHeaders(); ...
go
func (m Message) LookupSignature(kid string) []*Signature { var sigs []*Signature for _, sig := range m.signatures { if hdr := sig.PublicHeaders(); hdr != nil { hdrKeyId, ok := hdr.Get(KeyIDKey) if ok && hdrKeyId == kid { sigs = append(sigs, sig) continue } } if hdr := sig.ProtectedHeaders(); ...
[ "func", "(", "m", "Message", ")", "LookupSignature", "(", "kid", "string", ")", "[", "]", "*", "Signature", "{", "var", "sigs", "[", "]", "*", "Signature", "\n", "for", "_", ",", "sig", ":=", "range", "m", ".", "signatures", "{", "if", "hdr", ":=",...
// LookupSignature looks up a particular signature entry using // the `kid` value
[ "LookupSignature", "looks", "up", "a", "particular", "signature", "entry", "using", "the", "kid", "value" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/message.go#L25-L45
143,261
lestrrat-go/jwx
jwe/interface.go
NewErrUnsupportedAlgorithm
func NewErrUnsupportedAlgorithm(alg, purpose string) errUnsupportedAlgorithm { return errUnsupportedAlgorithm{alg: alg, purpose: purpose} }
go
func NewErrUnsupportedAlgorithm(alg, purpose string) errUnsupportedAlgorithm { return errUnsupportedAlgorithm{alg: alg, purpose: purpose} }
[ "func", "NewErrUnsupportedAlgorithm", "(", "alg", ",", "purpose", "string", ")", "errUnsupportedAlgorithm", "{", "return", "errUnsupportedAlgorithm", "{", "alg", ":", "alg", ",", "purpose", ":", "purpose", "}", "\n", "}" ]
// NewErrUnsupportedAlgorithm creates a new UnsupportedAlgorithm error
[ "NewErrUnsupportedAlgorithm", "creates", "a", "new", "UnsupportedAlgorithm", "error" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/interface.go#L31-L33
143,262
lestrrat-go/jwx
jwe/interface.go
Error
func (e errUnsupportedAlgorithm) Error() string { return fmt.Sprintf("unsupported algorithm '%s' for %s", e.alg, e.purpose) }
go
func (e errUnsupportedAlgorithm) Error() string { return fmt.Sprintf("unsupported algorithm '%s' for %s", e.alg, e.purpose) }
[ "func", "(", "e", "errUnsupportedAlgorithm", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "alg", ",", "e", ".", "purpose", ")", "\n", "}" ]
// Error returns the string representation of the error
[ "Error", "returns", "the", "string", "representation", "of", "the", "error" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/interface.go#L36-L38
143,263
lestrrat-go/jwx
jws/jws.go
Sign
func Sign(payload []byte, alg jwa.SignatureAlgorithm, key interface{}, options ...Option) ([]byte, error) { var hdrs Headers = &StandardHeaders{} for _, o := range options { switch o.Name() { case optkeyHeaders: hdrs = o.Value().(Headers) } } signer, err := sign.New(alg) if err != nil { return nil, err...
go
func Sign(payload []byte, alg jwa.SignatureAlgorithm, key interface{}, options ...Option) ([]byte, error) { var hdrs Headers = &StandardHeaders{} for _, o := range options { switch o.Name() { case optkeyHeaders: hdrs = o.Value().(Headers) } } signer, err := sign.New(alg) if err != nil { return nil, err...
[ "func", "Sign", "(", "payload", "[", "]", "byte", ",", "alg", "jwa", ".", "SignatureAlgorithm", ",", "key", "interface", "{", "}", ",", "options", "...", "Option", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "hdrs", "Headers", "=", "...
// Sign generates a signature for the given payload, and serializes // it in compact serialization format. In this format you may NOT use // multiple signers. // // If you would like to pass custom headers, use the WithHeaders option.
[ "Sign", "generates", "a", "signature", "for", "the", "given", "payload", "and", "serializes", "it", "in", "compact", "serialization", "format", ".", "In", "this", "format", "you", "may", "NOT", "use", "multiple", "signers", ".", "If", "you", "would", "like",...
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L87-L141
143,264
lestrrat-go/jwx
jws/jws.go
SignLiteral
func SignLiteral(payload []byte, alg jwa.SignatureAlgorithm, key interface{}, headers []byte) ([]byte, error) { signer, err := sign.New(alg) if err != nil { return nil, errors.Wrap(err, `failed to create signer`) } var buf bytes.Buffer enc := base64.NewEncoder(base64.RawURLEncoding, &buf) if _, err := enc.Wri...
go
func SignLiteral(payload []byte, alg jwa.SignatureAlgorithm, key interface{}, headers []byte) ([]byte, error) { signer, err := sign.New(alg) if err != nil { return nil, errors.Wrap(err, `failed to create signer`) } var buf bytes.Buffer enc := base64.NewEncoder(base64.RawURLEncoding, &buf) if _, err := enc.Wri...
[ "func", "SignLiteral", "(", "payload", "[", "]", "byte", ",", "alg", "jwa", ".", "SignatureAlgorithm", ",", "key", "interface", "{", "}", ",", "headers", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "signer", ",", "err", ":...
// SignLiteral generates a signature for the given payload and headers, and serializes // it in compact serialization format. In this format you may NOT use // multiple signers. //
[ "SignLiteral", "generates", "a", "signature", "for", "the", "given", "payload", "and", "headers", "and", "serializes", "it", "in", "compact", "serialization", "format", ".", "In", "this", "format", "you", "may", "NOT", "use", "multiple", "signers", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L147-L187
143,265
lestrrat-go/jwx
jws/jws.go
SignMulti
func SignMulti(payload []byte, options ...Option) ([]byte, error) { var signers []PayloadSigner for _, o := range options { switch o.Name() { case optkeyPayloadSigner: signers = append(signers, o.Value().(PayloadSigner)) } } if len(signers) == 0 { return nil, errors.New(`no signers provided`) } var r...
go
func SignMulti(payload []byte, options ...Option) ([]byte, error) { var signers []PayloadSigner for _, o := range options { switch o.Name() { case optkeyPayloadSigner: signers = append(signers, o.Value().(PayloadSigner)) } } if len(signers) == 0 { return nil, errors.New(`no signers provided`) } var r...
[ "func", "SignMulti", "(", "payload", "[", "]", "byte", ",", "options", "...", "Option", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "signers", "[", "]", "PayloadSigner", "\n", "for", "_", ",", "o", ":=", "range", "options", "{", "swi...
// SignMulti accepts multiple signers via the options parameter, // and creates a JWS in JSON serialization format that contains // signatures from applying aforementioned signers.
[ "SignMulti", "accepts", "multiple", "signers", "via", "the", "options", "parameter", "and", "creates", "a", "JWS", "in", "JSON", "serialization", "format", "that", "contains", "signatures", "from", "applying", "aforementioned", "signers", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L192-L239
143,266
lestrrat-go/jwx
jws/jws.go
VerifyWithJKU
func VerifyWithJKU(buf []byte, jwkurl string) ([]byte, error) { key, err := jwk.FetchHTTP(jwkurl) if err != nil { return nil, errors.Wrap(err, `failed to fetch jwk via HTTP`) } return VerifyWithJWKSet(buf, key, nil) }
go
func VerifyWithJKU(buf []byte, jwkurl string) ([]byte, error) { key, err := jwk.FetchHTTP(jwkurl) if err != nil { return nil, errors.Wrap(err, `failed to fetch jwk via HTTP`) } return VerifyWithJWKSet(buf, key, nil) }
[ "func", "VerifyWithJKU", "(", "buf", "[", "]", "byte", ",", "jwkurl", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "key", ",", "err", ":=", "jwk", ".", "FetchHTTP", "(", "jwkurl", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// VerifyWithJKU verifies the JWS message using a remote JWK // file represented in the url.
[ "VerifyWithJKU", "verifies", "the", "JWS", "message", "using", "a", "remote", "JWK", "file", "represented", "in", "the", "url", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L327-L334
143,267
lestrrat-go/jwx
jws/jws.go
VerifyWithJWK
func VerifyWithJWK(buf []byte, key jwk.Key) (payload []byte, err error) { keyval, err := key.Materialize() if err != nil { return nil, errors.Wrap(err, `failed to materialize jwk.Key`) } payload, err = Verify(buf, jwa.SignatureAlgorithm(key.Algorithm()), keyval) if err != nil { return nil, errors.Wrap(err, "...
go
func VerifyWithJWK(buf []byte, key jwk.Key) (payload []byte, err error) { keyval, err := key.Materialize() if err != nil { return nil, errors.Wrap(err, `failed to materialize jwk.Key`) } payload, err = Verify(buf, jwa.SignatureAlgorithm(key.Algorithm()), keyval) if err != nil { return nil, errors.Wrap(err, "...
[ "func", "VerifyWithJWK", "(", "buf", "[", "]", "byte", ",", "key", "jwk", ".", "Key", ")", "(", "payload", "[", "]", "byte", ",", "err", "error", ")", "{", "keyval", ",", "err", ":=", "key", ".", "Materialize", "(", ")", "\n", "if", "err", "!=", ...
// VerifyWithJWK verifies the JWS message using the specified JWK
[ "VerifyWithJWK", "verifies", "the", "JWS", "message", "using", "the", "specified", "JWK" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L337-L349
143,268
lestrrat-go/jwx
jws/jws.go
VerifyWithJWKSet
func VerifyWithJWKSet(buf []byte, keyset *jwk.Set, keyaccept JWKAcceptFunc) (payload []byte, err error) { if keyaccept == nil { keyaccept = DefaultJWKAcceptor } for _, key := range keyset.Keys { if !keyaccept(key) { continue } payload, err := VerifyWithJWK(buf, key) if err == nil { return payload,...
go
func VerifyWithJWKSet(buf []byte, keyset *jwk.Set, keyaccept JWKAcceptFunc) (payload []byte, err error) { if keyaccept == nil { keyaccept = DefaultJWKAcceptor } for _, key := range keyset.Keys { if !keyaccept(key) { continue } payload, err := VerifyWithJWK(buf, key) if err == nil { return payload,...
[ "func", "VerifyWithJWKSet", "(", "buf", "[", "]", "byte", ",", "keyset", "*", "jwk", ".", "Set", ",", "keyaccept", "JWKAcceptFunc", ")", "(", "payload", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "keyaccept", "==", "nil", "{", "keyaccept", ...
// VerifyWithJWKSet verifies the JWS message using JWK key set. // By default it will only pick up keys that have the "use" key // set to either "sig" or "enc", but you can override it by // providing a keyaccept function.
[ "VerifyWithJWKSet", "verifies", "the", "JWS", "message", "using", "JWK", "key", "set", ".", "By", "default", "it", "will", "only", "pick", "up", "keys", "that", "have", "the", "use", "key", "set", "to", "either", "sig", "or", "enc", "but", "you", "can", ...
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L355-L373
143,269
lestrrat-go/jwx
jws/jws.go
Parse
func Parse(src io.Reader) (m *Message, err error) { rdr := bufio.NewReader(src) var first rune for { r, _, err := rdr.ReadRune() if err != nil { return nil, errors.Wrap(err, `failed to read rune`) } if !unicode.IsSpace(r) { first = r rdr.UnreadRune() break } } var parser func(io.Reader) (*M...
go
func Parse(src io.Reader) (m *Message, err error) { rdr := bufio.NewReader(src) var first rune for { r, _, err := rdr.ReadRune() if err != nil { return nil, errors.Wrap(err, `failed to read rune`) } if !unicode.IsSpace(r) { first = r rdr.UnreadRune() break } } var parser func(io.Reader) (*M...
[ "func", "Parse", "(", "src", "io", ".", "Reader", ")", "(", "m", "*", "Message", ",", "err", "error", ")", "{", "rdr", ":=", "bufio", ".", "NewReader", "(", "src", ")", "\n", "var", "first", "rune", "\n", "for", "{", "r", ",", "_", ",", "err", ...
// Parse parses contents from the given source and creates a jws.Message // struct. The input can be in either compact or full JSON serialization.
[ "Parse", "parses", "contents", "from", "the", "given", "source", "and", "creates", "a", "jws", ".", "Message", "struct", ".", "The", "input", "can", "be", "in", "either", "compact", "or", "full", "JSON", "serialization", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L377-L406
143,270
lestrrat-go/jwx
jws/jws.go
parseCompact
func parseCompact(rdr io.Reader) (m *Message, err error) { protected, payload, signature, err := SplitCompact(rdr) if err != nil { return nil, errors.Wrap(err, `invalid compact serialization format`) } decodedHeader := make([]byte, base64.RawURLEncoding.DecodedLen(len(protected))) if _, err := base64.RawURLEnc...
go
func parseCompact(rdr io.Reader) (m *Message, err error) { protected, payload, signature, err := SplitCompact(rdr) if err != nil { return nil, errors.Wrap(err, `invalid compact serialization format`) } decodedHeader := make([]byte, base64.RawURLEncoding.DecodedLen(len(protected))) if _, err := base64.RawURLEnc...
[ "func", "parseCompact", "(", "rdr", "io", ".", "Reader", ")", "(", "m", "*", "Message", ",", "err", "error", ")", "{", "protected", ",", "payload", ",", "signature", ",", "err", ":=", "SplitCompact", "(", "rdr", ")", "\n", "if", "err", "!=", "nil", ...
// parseCompact parses a JWS value serialized via compact serialization.
[ "parseCompact", "parses", "a", "JWS", "value", "serialized", "via", "compact", "serialization", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/jws.go#L525-L558
143,271
lestrrat-go/jwx
jws/verify/verify.go
New
func New(alg jwa.SignatureAlgorithm) (Verifier, error) { switch alg { case jwa.RS256, jwa.RS384, jwa.RS512, jwa.PS256, jwa.PS384, jwa.PS512: return newRSA(alg) case jwa.ES256, jwa.ES384, jwa.ES512: return newECDSA(alg) case jwa.HS256, jwa.HS384, jwa.HS512: return newHMAC(alg) default: return nil, errors.Er...
go
func New(alg jwa.SignatureAlgorithm) (Verifier, error) { switch alg { case jwa.RS256, jwa.RS384, jwa.RS512, jwa.PS256, jwa.PS384, jwa.PS512: return newRSA(alg) case jwa.ES256, jwa.ES384, jwa.ES512: return newECDSA(alg) case jwa.HS256, jwa.HS384, jwa.HS512: return newHMAC(alg) default: return nil, errors.Er...
[ "func", "New", "(", "alg", "jwa", ".", "SignatureAlgorithm", ")", "(", "Verifier", ",", "error", ")", "{", "switch", "alg", "{", "case", "jwa", ".", "RS256", ",", "jwa", ".", "RS384", ",", "jwa", ".", "RS512", ",", "jwa", ".", "PS256", ",", "jwa", ...
// New creates a new JWS verifier using the specified algorithm // and the public key
[ "New", "creates", "a", "new", "JWS", "verifier", "using", "the", "specified", "algorithm", "and", "the", "public", "key" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jws/verify/verify.go#L10-L21
143,272
lestrrat-go/jwx
jwt/jwt.go
ParseString
func ParseString(s string, options ...Option) (*Token, error) { return Parse(strings.NewReader(s), options...) }
go
func ParseString(s string, options ...Option) (*Token, error) { return Parse(strings.NewReader(s), options...) }
[ "func", "ParseString", "(", "s", "string", ",", "options", "...", "Option", ")", "(", "*", "Token", ",", "error", ")", "{", "return", "Parse", "(", "strings", ".", "NewReader", "(", "s", ")", ",", "options", "...", ")", "\n", "}" ]
// ParseString calls Parse with the given string
[ "ParseString", "calls", "Parse", "with", "the", "given", "string" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwt/jwt.go#L19-L21
143,273
lestrrat-go/jwx
jwt/jwt.go
ParseBytes
func ParseBytes(s []byte, options ...Option) (*Token, error) { return Parse(bytes.NewReader(s), options...) }
go
func ParseBytes(s []byte, options ...Option) (*Token, error) { return Parse(bytes.NewReader(s), options...) }
[ "func", "ParseBytes", "(", "s", "[", "]", "byte", ",", "options", "...", "Option", ")", "(", "*", "Token", ",", "error", ")", "{", "return", "Parse", "(", "bytes", ".", "NewReader", "(", "s", ")", ",", "options", "...", ")", "\n", "}" ]
// ParseString calls Parse with the given byte sequence
[ "ParseString", "calls", "Parse", "with", "the", "given", "byte", "sequence" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwt/jwt.go#L24-L26
143,274
lestrrat-go/jwx
jwt/jwt.go
Sign
func (t *Token) Sign(method jwa.SignatureAlgorithm, key interface{}) ([]byte, error) { buf, err := json.Marshal(t) if err != nil { return nil, errors.Wrap(err, `failed to marshal token`) } var hdr jws.StandardHeaders if hdr.Set(`alg`, method.String()) != nil { return nil, errors.Wrap(err, `failed to sign payl...
go
func (t *Token) Sign(method jwa.SignatureAlgorithm, key interface{}) ([]byte, error) { buf, err := json.Marshal(t) if err != nil { return nil, errors.Wrap(err, `failed to marshal token`) } var hdr jws.StandardHeaders if hdr.Set(`alg`, method.String()) != nil { return nil, errors.Wrap(err, `failed to sign payl...
[ "func", "(", "t", "*", "Token", ")", "Sign", "(", "method", "jwa", ".", "SignatureAlgorithm", ",", "key", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "buf", ",", "err", ":=", "json", ".", "Marshal", "(", "t", ")", ...
// Sign is a convenience function to create a signed JWT token serialized in // compact form. `key` must match the key type required by the given // signature method `method`
[ "Sign", "is", "a", "convenience", "function", "to", "create", "a", "signed", "JWT", "token", "serialized", "in", "compact", "form", ".", "key", "must", "match", "the", "key", "type", "required", "by", "the", "given", "signature", "method", "method" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwt/jwt.go#L87-L106
143,275
lestrrat-go/jwx
buffer/buffer.go
FromUint
func FromUint(v uint64) Buffer { data := make([]byte, 8) binary.BigEndian.PutUint64(data, v) i := 0 for ; i < len(data); i++ { if data[i] != 0x0 { break } } return Buffer(data[i:]) }
go
func FromUint(v uint64) Buffer { data := make([]byte, 8) binary.BigEndian.PutUint64(data, v) i := 0 for ; i < len(data); i++ { if data[i] != 0x0 { break } } return Buffer(data[i:]) }
[ "func", "FromUint", "(", "v", "uint64", ")", "Buffer", "{", "data", ":=", "make", "(", "[", "]", "byte", ",", "8", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "data", ",", "v", ")", "\n\n", "i", ":=", "0", "\n", "for", ";", "i...
// FromUint creates a `Buffer` from an unsigned int
[ "FromUint", "creates", "a", "Buffer", "from", "an", "unsigned", "int" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/buffer/buffer.go#L21-L32
143,276
lestrrat-go/jwx
buffer/buffer.go
FromBase64
func FromBase64(v []byte) (Buffer, error) { b := Buffer{} if err := b.Base64Decode(v); err != nil { return Buffer(nil), errors.Wrap(err, "failed to decode from base64") } return b, nil }
go
func FromBase64(v []byte) (Buffer, error) { b := Buffer{} if err := b.Base64Decode(v); err != nil { return Buffer(nil), errors.Wrap(err, "failed to decode from base64") } return b, nil }
[ "func", "FromBase64", "(", "v", "[", "]", "byte", ")", "(", "Buffer", ",", "error", ")", "{", "b", ":=", "Buffer", "{", "}", "\n", "if", "err", ":=", "b", ".", "Base64Decode", "(", "v", ")", ";", "err", "!=", "nil", "{", "return", "Buffer", "("...
// FromBase64 constructs a new Buffer from a base64 encoded data
[ "FromBase64", "constructs", "a", "new", "Buffer", "from", "a", "base64", "encoded", "data" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/buffer/buffer.go#L35-L42
143,277
lestrrat-go/jwx
buffer/buffer.go
NData
func (b Buffer) NData() []byte { buf := make([]byte, 4+b.Len()) binary.BigEndian.PutUint32(buf, uint32(b.Len())) copy(buf[4:], b.Bytes()) return buf }
go
func (b Buffer) NData() []byte { buf := make([]byte, 4+b.Len()) binary.BigEndian.PutUint32(buf, uint32(b.Len())) copy(buf[4:], b.Bytes()) return buf }
[ "func", "(", "b", "Buffer", ")", "NData", "(", ")", "[", "]", "byte", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "4", "+", "b", ".", "Len", "(", ")", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint32", "(", "buf", ",", "uint32...
// NData returns Datalen || Data, where Datalen is a 32 bit counter for // the length of the following data, and Data is the octets that comprise // the buffer data
[ "NData", "returns", "Datalen", "||", "Data", "where", "Datalen", "is", "a", "32", "bit", "counter", "for", "the", "length", "of", "the", "following", "data", "and", "Data", "is", "the", "octets", "that", "comprise", "the", "buffer", "data" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/buffer/buffer.go#L61-L67
143,278
lestrrat-go/jwx
buffer/buffer.go
Base64Encode
func (b Buffer) Base64Encode() ([]byte, error) { enc := base64.RawURLEncoding out := make([]byte, enc.EncodedLen(len(b))) enc.Encode(out, b) return out, nil }
go
func (b Buffer) Base64Encode() ([]byte, error) { enc := base64.RawURLEncoding out := make([]byte, enc.EncodedLen(len(b))) enc.Encode(out, b) return out, nil }
[ "func", "(", "b", "Buffer", ")", "Base64Encode", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "enc", ":=", "base64", ".", "RawURLEncoding", "\n", "out", ":=", "make", "(", "[", "]", "byte", ",", "enc", ".", "EncodedLen", "(", "len", "...
// Base64Encode encodes the contents of the Buffer using base64.RawURLEncoding
[ "Base64Encode", "encodes", "the", "contents", "of", "the", "Buffer", "using", "base64", ".", "RawURLEncoding" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/buffer/buffer.go#L80-L85
143,279
lestrrat-go/jwx
buffer/buffer.go
Base64Decode
func (b *Buffer) Base64Decode(v []byte) error { enc := base64.RawURLEncoding out := make([]byte, enc.DecodedLen(len(v))) n, err := enc.Decode(out, v) if err != nil { return errors.Wrap(err, "failed to decode from base64") } out = out[:n] *b = Buffer(out) return nil }
go
func (b *Buffer) Base64Decode(v []byte) error { enc := base64.RawURLEncoding out := make([]byte, enc.DecodedLen(len(v))) n, err := enc.Decode(out, v) if err != nil { return errors.Wrap(err, "failed to decode from base64") } out = out[:n] *b = Buffer(out) return nil }
[ "func", "(", "b", "*", "Buffer", ")", "Base64Decode", "(", "v", "[", "]", "byte", ")", "error", "{", "enc", ":=", "base64", ".", "RawURLEncoding", "\n", "out", ":=", "make", "(", "[", "]", "byte", ",", "enc", ".", "DecodedLen", "(", "len", "(", "...
// Base64Decode decodes the contents of the Buffer using base64.RawURLEncoding
[ "Base64Decode", "decodes", "the", "contents", "of", "the", "Buffer", "using", "base64", ".", "RawURLEncoding" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/buffer/buffer.go#L88-L98
143,280
lestrrat-go/jwx
buffer/buffer.go
MarshalJSON
func (b Buffer) MarshalJSON() ([]byte, error) { v, err := b.Base64Encode() if err != nil { return nil, errors.Wrap(err, "failed to encode to base64") } return json.Marshal(string(v)) }
go
func (b Buffer) MarshalJSON() ([]byte, error) { v, err := b.Base64Encode() if err != nil { return nil, errors.Wrap(err, "failed to encode to base64") } return json.Marshal(string(v)) }
[ "func", "(", "b", "Buffer", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "v", ",", "err", ":=", "b", ".", "Base64Encode", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap"...
// MarshalJSON marshals the buffer into JSON format after encoding the buffer // with base64.RawURLEncoding
[ "MarshalJSON", "marshals", "the", "buffer", "into", "JSON", "format", "after", "encoding", "the", "buffer", "with", "base64", ".", "RawURLEncoding" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/buffer/buffer.go#L102-L108
143,281
lestrrat-go/jwx
buffer/buffer.go
UnmarshalJSON
func (b *Buffer) UnmarshalJSON(data []byte) error { var x string if err := json.Unmarshal(data, &x); err != nil { return errors.Wrap(err, "failed to unmarshal JSON") } return b.Base64Decode([]byte(x)) }
go
func (b *Buffer) UnmarshalJSON(data []byte) error { var x string if err := json.Unmarshal(data, &x); err != nil { return errors.Wrap(err, "failed to unmarshal JSON") } return b.Base64Decode([]byte(x)) }
[ "func", "(", "b", "*", "Buffer", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "x", "string", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "x", ")", ";", "err", "!=", "nil", "{", "re...
// UnmarshalJSON unmarshals from a JSON string into a Buffer, after decoding it // with base64.RawURLEncoding
[ "UnmarshalJSON", "unmarshals", "from", "a", "JSON", "string", "into", "a", "Buffer", "after", "decoding", "it", "with", "base64", ".", "RawURLEncoding" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/buffer/buffer.go#L112-L118
143,282
lestrrat-go/jwx
jwe/key_generate.go
KeyGenerate
func (g StaticKeyGenerate) KeyGenerate() (ByteSource, error) { buf := make([]byte, g.KeySize()) copy(buf, g) return ByteKey(buf), nil }
go
func (g StaticKeyGenerate) KeyGenerate() (ByteSource, error) { buf := make([]byte, g.KeySize()) copy(buf, g) return ByteKey(buf), nil }
[ "func", "(", "g", "StaticKeyGenerate", ")", "KeyGenerate", "(", ")", "(", "ByteSource", ",", "error", ")", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "g", ".", "KeySize", "(", ")", ")", "\n", "copy", "(", "buf", ",", "g", ")", "\n", ...
// KeyGenerate returns the key
[ "KeyGenerate", "returns", "the", "key" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_generate.go#L27-L31
143,283
lestrrat-go/jwx
jwe/key_generate.go
KeyGenerate
func (g RandomKeyGenerate) KeyGenerate() (ByteSource, error) { buf := make([]byte, g.keysize) if _, err := io.ReadFull(rand.Reader, buf); err != nil { return nil, errors.Wrap(err, "failed to read from rand.Reader") } return ByteKey(buf), nil }
go
func (g RandomKeyGenerate) KeyGenerate() (ByteSource, error) { buf := make([]byte, g.keysize) if _, err := io.ReadFull(rand.Reader, buf); err != nil { return nil, errors.Wrap(err, "failed to read from rand.Reader") } return ByteKey(buf), nil }
[ "func", "(", "g", "RandomKeyGenerate", ")", "KeyGenerate", "(", ")", "(", "ByteSource", ",", "error", ")", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "g", ".", "keysize", ")", "\n", "if", "_", ",", "err", ":=", "io", ".", "ReadFull", "...
// KeyGenerate generates a random new key
[ "KeyGenerate", "generates", "a", "random", "new", "key" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_generate.go#L45-L51
143,284
lestrrat-go/jwx
jwe/key_generate.go
NewEcdhesKeyGenerate
func NewEcdhesKeyGenerate(alg jwa.KeyEncryptionAlgorithm, pubkey *ecdsa.PublicKey) (*EcdhesKeyGenerate, error) { var keysize int switch alg { case jwa.ECDH_ES: return nil, errors.New("unimplemented") case jwa.ECDH_ES_A128KW: keysize = 16 case jwa.ECDH_ES_A192KW: keysize = 24 case jwa.ECDH_ES_A256KW: keysi...
go
func NewEcdhesKeyGenerate(alg jwa.KeyEncryptionAlgorithm, pubkey *ecdsa.PublicKey) (*EcdhesKeyGenerate, error) { var keysize int switch alg { case jwa.ECDH_ES: return nil, errors.New("unimplemented") case jwa.ECDH_ES_A128KW: keysize = 16 case jwa.ECDH_ES_A192KW: keysize = 24 case jwa.ECDH_ES_A256KW: keysi...
[ "func", "NewEcdhesKeyGenerate", "(", "alg", "jwa", ".", "KeyEncryptionAlgorithm", ",", "pubkey", "*", "ecdsa", ".", "PublicKey", ")", "(", "*", "EcdhesKeyGenerate", ",", "error", ")", "{", "var", "keysize", "int", "\n", "switch", "alg", "{", "case", "jwa", ...
// NewEcdhesKeyGenerate creates a new key generator using ECDH-ES
[ "NewEcdhesKeyGenerate", "creates", "a", "new", "key", "generator", "using", "ECDH", "-", "ES" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_generate.go#L54-L74
143,285
lestrrat-go/jwx
jwe/key_generate.go
KeyGenerate
func (g EcdhesKeyGenerate) KeyGenerate() (ByteSource, error) { priv, err := ecdsa.GenerateKey(g.pubkey.Curve, rand.Reader) if err != nil { return nil, errors.Wrap(err, "failed to generate key for ECDH-ES") } pubinfo := make([]byte, 4) binary.BigEndian.PutUint32(pubinfo, uint32(g.keysize)*8) z, _ := priv.Publi...
go
func (g EcdhesKeyGenerate) KeyGenerate() (ByteSource, error) { priv, err := ecdsa.GenerateKey(g.pubkey.Curve, rand.Reader) if err != nil { return nil, errors.Wrap(err, "failed to generate key for ECDH-ES") } pubinfo := make([]byte, 4) binary.BigEndian.PutUint32(pubinfo, uint32(g.keysize)*8) z, _ := priv.Publi...
[ "func", "(", "g", "EcdhesKeyGenerate", ")", "KeyGenerate", "(", ")", "(", "ByteSource", ",", "error", ")", "{", "priv", ",", "err", ":=", "ecdsa", ".", "GenerateKey", "(", "g", ".", "pubkey", ".", "Curve", ",", "rand", ".", "Reader", ")", "\n", "if",...
// KeyGenerate generates new keys using ECDH-ES
[ "KeyGenerate", "generates", "new", "keys", "using", "ECDH", "-", "ES" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_generate.go#L82-L100
143,286
lestrrat-go/jwx
jwe/message.go
Get
func (h *Header) Get(key string) (interface{}, error) { switch key { case "alg": return h.Algorithm, nil case "apu": return h.AgreementPartyUInfo, nil case "apv": return h.AgreementPartyVInfo, nil case "enc": return h.ContentEncryption, nil case "epk": return h.EphemeralPublicKey, nil case "cty": ret...
go
func (h *Header) Get(key string) (interface{}, error) { switch key { case "alg": return h.Algorithm, nil case "apu": return h.AgreementPartyUInfo, nil case "apv": return h.AgreementPartyVInfo, nil case "enc": return h.ContentEncryption, nil case "epk": return h.EphemeralPublicKey, nil case "cty": ret...
[ "func", "(", "h", "*", "Header", ")", "Get", "(", "key", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "switch", "key", "{", "case", "\"", "\"", ":", "return", "h", ".", "Algorithm", ",", "nil", "\n", "case", "\"", "\"", ":...
// Get returns the header key
[ "Get", "returns", "the", "header", "key" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/message.go#L39-L76
143,287
lestrrat-go/jwx
jwe/message.go
Base64Encode
func (e EncodedHeader) Base64Encode() ([]byte, error) { buf, err := json.Marshal(e.Header) if err != nil { return nil, errors.Wrap(err, "failed to marshal encoded header into JSON") } buf, err = buffer.Buffer(buf).Base64Encode() if err != nil { return nil, errors.Wrap(err, "failed to base64 encode encoded hea...
go
func (e EncodedHeader) Base64Encode() ([]byte, error) { buf, err := json.Marshal(e.Header) if err != nil { return nil, errors.Wrap(err, "failed to marshal encoded header into JSON") } buf, err = buffer.Buffer(buf).Base64Encode() if err != nil { return nil, errors.Wrap(err, "failed to base64 encode encoded hea...
[ "func", "(", "e", "EncodedHeader", ")", "Base64Encode", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "buf", ",", "err", ":=", "json", ".", "Marshal", "(", "e", ".", "Header", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// Base64Encode creates the base64 encoded version of the JSON // representation of this header
[ "Base64Encode", "creates", "the", "base64", "encoded", "version", "of", "the", "JSON", "representation", "of", "this", "header" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/message.go#L395-L407
143,288
lestrrat-go/jwx
jwt/token_gen.go
UnmarshalJSON
func (t *Token) UnmarshalJSON(data []byte) error { var m map[string]interface{} if err := json.Unmarshal(data, &m); err != nil { return errors.Wrap(err, `failed to unmarshal token`) } for name, value := range m { if err := t.Set(name, value); err != nil { return errors.Wrapf(err, `failed to set value for %s`...
go
func (t *Token) UnmarshalJSON(data []byte) error { var m map[string]interface{} if err := json.Unmarshal(data, &m); err != nil { return errors.Wrap(err, `failed to unmarshal token`) } for name, value := range m { if err := t.Set(name, value); err != nil { return errors.Wrapf(err, `failed to set value for %s`...
[ "func", "(", "t", "*", "Token", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "m", "map", "[", "string", "]", "interface", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "m", ...
// UnmarshalJSON deserializes data from a JSON data buffer into a Token
[ "UnmarshalJSON", "deserializes", "data", "from", "a", "JSON", "data", "buffer", "into", "a", "Token" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwt/token_gen.go#L311-L322
143,289
lestrrat-go/jwx
jwe/key_encrypt.go
NewKeyWrapEncrypt
func NewKeyWrapEncrypt(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (KeyWrapEncrypt, error) { return KeyWrapEncrypt{ alg: alg, sharedkey: sharedkey, }, nil }
go
func NewKeyWrapEncrypt(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (KeyWrapEncrypt, error) { return KeyWrapEncrypt{ alg: alg, sharedkey: sharedkey, }, nil }
[ "func", "NewKeyWrapEncrypt", "(", "alg", "jwa", ".", "KeyEncryptionAlgorithm", ",", "sharedkey", "[", "]", "byte", ")", "(", "KeyWrapEncrypt", ",", "error", ")", "{", "return", "KeyWrapEncrypt", "{", "alg", ":", "alg", ",", "sharedkey", ":", "sharedkey", ","...
// NewKeyWrapEncrypt creates a key-wrap encrypter using AES-CGM. // Although the name suggests otherwise, this does the decryption as well.
[ "NewKeyWrapEncrypt", "creates", "a", "key", "-", "wrap", "encrypter", "using", "AES", "-", "CGM", ".", "Although", "the", "name", "suggests", "otherwise", "this", "does", "the", "decryption", "as", "well", "." ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L25-L30
143,290
lestrrat-go/jwx
jwe/key_encrypt.go
KeyDecrypt
func (kw KeyWrapEncrypt) KeyDecrypt(enckey []byte) ([]byte, error) { block, err := aes.NewCipher(kw.sharedkey) if err != nil { return nil, errors.Wrap(err, "failed to create cipher from shared key") } cek, err := keyunwrap(block, enckey) if err != nil { return nil, errors.Wrap(err, "failed to unwrap data") }...
go
func (kw KeyWrapEncrypt) KeyDecrypt(enckey []byte) ([]byte, error) { block, err := aes.NewCipher(kw.sharedkey) if err != nil { return nil, errors.Wrap(err, "failed to create cipher from shared key") } cek, err := keyunwrap(block, enckey) if err != nil { return nil, errors.Wrap(err, "failed to unwrap data") }...
[ "func", "(", "kw", "KeyWrapEncrypt", ")", "KeyDecrypt", "(", "enckey", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "block", ",", "err", ":=", "aes", ".", "NewCipher", "(", "kw", ".", "sharedkey", ")", "\n", "if", "err", ...
// KeyDecrypt decrypts the encrypted key using AES-CGM key unwrap
[ "KeyDecrypt", "decrypts", "the", "encrypted", "key", "using", "AES", "-", "CGM", "key", "unwrap" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L43-L54
143,291
lestrrat-go/jwx
jwe/key_encrypt.go
KeyEncrypt
func (kw KeyWrapEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { block, err := aes.NewCipher(kw.sharedkey) if err != nil { return nil, errors.Wrap(err, "failed to create cipher from shared key") } encrypted, err := keywrap(block, cek) if err != nil { return nil, errors.Wrap(err, `keywrap: failed to wrap k...
go
func (kw KeyWrapEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { block, err := aes.NewCipher(kw.sharedkey) if err != nil { return nil, errors.Wrap(err, "failed to create cipher from shared key") } encrypted, err := keywrap(block, cek) if err != nil { return nil, errors.Wrap(err, `keywrap: failed to wrap k...
[ "func", "(", "kw", "KeyWrapEncrypt", ")", "KeyEncrypt", "(", "cek", "[", "]", "byte", ")", "(", "ByteSource", ",", "error", ")", "{", "block", ",", "err", ":=", "aes", ".", "NewCipher", "(", "kw", ".", "sharedkey", ")", "\n", "if", "err", "!=", "ni...
// KeyEncrypt encrypts the given content encryption key
[ "KeyEncrypt", "encrypts", "the", "given", "content", "encryption", "key" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L57-L67
143,292
lestrrat-go/jwx
jwe/key_encrypt.go
NewEcdhesKeyWrapEncrypt
func NewEcdhesKeyWrapEncrypt(alg jwa.KeyEncryptionAlgorithm, key *ecdsa.PublicKey) (*EcdhesKeyWrapEncrypt, error) { generator, err := NewEcdhesKeyGenerate(alg, key) if err != nil { return nil, errors.Wrap(err, "failed to create key generator") } return &EcdhesKeyWrapEncrypt{ algorithm: alg, generator: generat...
go
func NewEcdhesKeyWrapEncrypt(alg jwa.KeyEncryptionAlgorithm, key *ecdsa.PublicKey) (*EcdhesKeyWrapEncrypt, error) { generator, err := NewEcdhesKeyGenerate(alg, key) if err != nil { return nil, errors.Wrap(err, "failed to create key generator") } return &EcdhesKeyWrapEncrypt{ algorithm: alg, generator: generat...
[ "func", "NewEcdhesKeyWrapEncrypt", "(", "alg", "jwa", ".", "KeyEncryptionAlgorithm", ",", "key", "*", "ecdsa", ".", "PublicKey", ")", "(", "*", "EcdhesKeyWrapEncrypt", ",", "error", ")", "{", "generator", ",", "err", ":=", "NewEcdhesKeyGenerate", "(", "alg", "...
// NewEcdhesKeyWrapEncrypt creates a new key encrypter based on ECDH-ES
[ "NewEcdhesKeyWrapEncrypt", "creates", "a", "new", "key", "encrypter", "based", "on", "ECDH", "-", "ES" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L70-L79
143,293
lestrrat-go/jwx
jwe/key_encrypt.go
KeyEncrypt
func (kw EcdhesKeyWrapEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { kg, err := kw.generator.KeyGenerate() if err != nil { return nil, errors.Wrap(err, "failed to create key generator") } bwpk, ok := kg.(ByteWithECPrivateKey) if !ok { return nil, errors.New("key generator generated invalid key (expecte...
go
func (kw EcdhesKeyWrapEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { kg, err := kw.generator.KeyGenerate() if err != nil { return nil, errors.Wrap(err, "failed to create key generator") } bwpk, ok := kg.(ByteWithECPrivateKey) if !ok { return nil, errors.New("key generator generated invalid key (expecte...
[ "func", "(", "kw", "EcdhesKeyWrapEncrypt", ")", "KeyEncrypt", "(", "cek", "[", "]", "byte", ")", "(", "ByteSource", ",", "error", ")", "{", "kg", ",", "err", ":=", "kw", ".", "generator", ".", "KeyGenerate", "(", ")", "\n", "if", "err", "!=", "nil", ...
// KeyEncrypt encrypts the content encryption key using ECDH-ES
[ "KeyEncrypt", "encrypts", "the", "content", "encryption", "key", "using", "ECDH", "-", "ES" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L92-L116
143,294
lestrrat-go/jwx
jwe/key_encrypt.go
NewEcdhesKeyWrapDecrypt
func NewEcdhesKeyWrapDecrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *ecdsa.PublicKey, apu, apv []byte, privkey *ecdsa.PrivateKey) *EcdhesKeyWrapDecrypt { return &EcdhesKeyWrapDecrypt{ algorithm: alg, apu: apu, apv: apv, privkey: privkey, pubkey: pubkey, } }
go
func NewEcdhesKeyWrapDecrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *ecdsa.PublicKey, apu, apv []byte, privkey *ecdsa.PrivateKey) *EcdhesKeyWrapDecrypt { return &EcdhesKeyWrapDecrypt{ algorithm: alg, apu: apu, apv: apv, privkey: privkey, pubkey: pubkey, } }
[ "func", "NewEcdhesKeyWrapDecrypt", "(", "alg", "jwa", ".", "KeyEncryptionAlgorithm", ",", "pubkey", "*", "ecdsa", ".", "PublicKey", ",", "apu", ",", "apv", "[", "]", "byte", ",", "privkey", "*", "ecdsa", ".", "PrivateKey", ")", "*", "EcdhesKeyWrapDecrypt", "...
// NewEcdhesKeyWrapDecrypt creates a new key decrypter using ECDH-ES
[ "NewEcdhesKeyWrapDecrypt", "creates", "a", "new", "key", "decrypter", "using", "ECDH", "-", "ES" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L119-L127
143,295
lestrrat-go/jwx
jwe/key_encrypt.go
KeyDecrypt
func (kw EcdhesKeyWrapDecrypt) KeyDecrypt(enckey []byte) ([]byte, error) { var keysize uint32 switch kw.algorithm { case jwa.ECDH_ES_A128KW: keysize = 16 case jwa.ECDH_ES_A192KW: keysize = 24 case jwa.ECDH_ES_A256KW: keysize = 32 default: return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid ECDH-ES k...
go
func (kw EcdhesKeyWrapDecrypt) KeyDecrypt(enckey []byte) ([]byte, error) { var keysize uint32 switch kw.algorithm { case jwa.ECDH_ES_A128KW: keysize = 16 case jwa.ECDH_ES_A192KW: keysize = 24 case jwa.ECDH_ES_A256KW: keysize = 32 default: return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid ECDH-ES k...
[ "func", "(", "kw", "EcdhesKeyWrapDecrypt", ")", "KeyDecrypt", "(", "enckey", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "keysize", "uint32", "\n", "switch", "kw", ".", "algorithm", "{", "case", "jwa", ".", "ECDH_ES_A12...
// KeyDecrypt decrypts the encrypted key using ECDH-ES
[ "KeyDecrypt", "decrypts", "the", "encrypted", "key", "using", "ECDH", "-", "ES" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L135-L165
143,296
lestrrat-go/jwx
jwe/key_encrypt.go
NewRSAOAEPKeyEncrypt
func NewRSAOAEPKeyEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAOAEPKeyEncrypt, error) { switch alg { case jwa.RSA_OAEP, jwa.RSA_OAEP_256: default: return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid RSA OAEP encrypt algorithm") } return &RSAOAEPKeyEncrypt{ alg: alg, pubkey: pu...
go
func NewRSAOAEPKeyEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAOAEPKeyEncrypt, error) { switch alg { case jwa.RSA_OAEP, jwa.RSA_OAEP_256: default: return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid RSA OAEP encrypt algorithm") } return &RSAOAEPKeyEncrypt{ alg: alg, pubkey: pu...
[ "func", "NewRSAOAEPKeyEncrypt", "(", "alg", "jwa", ".", "KeyEncryptionAlgorithm", ",", "pubkey", "*", "rsa", ".", "PublicKey", ")", "(", "*", "RSAOAEPKeyEncrypt", ",", "error", ")", "{", "switch", "alg", "{", "case", "jwa", ".", "RSA_OAEP", ",", "jwa", "."...
// NewRSAOAEPKeyEncrypt creates a new key encrypter using RSA OAEP
[ "NewRSAOAEPKeyEncrypt", "creates", "a", "new", "key", "encrypter", "using", "RSA", "OAEP" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L168-L178
143,297
lestrrat-go/jwx
jwe/key_encrypt.go
NewRSAPKCSKeyEncrypt
func NewRSAPKCSKeyEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAPKCSKeyEncrypt, error) { switch alg { case jwa.RSA1_5: default: return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid RSA PKCS encrypt algorithm") } return &RSAPKCSKeyEncrypt{ alg: alg, pubkey: pubkey, }, nil }
go
func NewRSAPKCSKeyEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAPKCSKeyEncrypt, error) { switch alg { case jwa.RSA1_5: default: return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid RSA PKCS encrypt algorithm") } return &RSAPKCSKeyEncrypt{ alg: alg, pubkey: pubkey, }, nil }
[ "func", "NewRSAPKCSKeyEncrypt", "(", "alg", "jwa", ".", "KeyEncryptionAlgorithm", ",", "pubkey", "*", "rsa", ".", "PublicKey", ")", "(", "*", "RSAPKCSKeyEncrypt", ",", "error", ")", "{", "switch", "alg", "{", "case", "jwa", ".", "RSA1_5", ":", "default", "...
// NewRSAPKCSKeyEncrypt creates a new key encrypter using PKCS1v15
[ "NewRSAPKCSKeyEncrypt", "creates", "a", "new", "key", "encrypter", "using", "PKCS1v15" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L181-L192
143,298
lestrrat-go/jwx
jwe/key_encrypt.go
KeyEncrypt
func (e RSAPKCSKeyEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { if e.alg != jwa.RSA1_5 { return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid RSA PKCS encrypt algorithm") } encrypted, err := rsa.EncryptPKCS1v15(rand.Reader, e.pubkey, cek) if err != nil { return nil, errors.Wrap(err, "failed to encr...
go
func (e RSAPKCSKeyEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { if e.alg != jwa.RSA1_5 { return nil, errors.Wrap(ErrUnsupportedAlgorithm, "invalid RSA PKCS encrypt algorithm") } encrypted, err := rsa.EncryptPKCS1v15(rand.Reader, e.pubkey, cek) if err != nil { return nil, errors.Wrap(err, "failed to encr...
[ "func", "(", "e", "RSAPKCSKeyEncrypt", ")", "KeyEncrypt", "(", "cek", "[", "]", "byte", ")", "(", "ByteSource", ",", "error", ")", "{", "if", "e", ".", "alg", "!=", "jwa", ".", "RSA1_5", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "ErrUn...
// KeyEncrypt encrypts the content encryption key using RSA PKCS1v15
[ "KeyEncrypt", "encrypts", "the", "content", "encryption", "key", "using", "RSA", "PKCS1v15" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L215-L224
143,299
lestrrat-go/jwx
jwe/key_encrypt.go
KeyEncrypt
func (e RSAOAEPKeyEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { var hash hash.Hash switch e.alg { case jwa.RSA_OAEP: hash = sha1.New() case jwa.RSA_OAEP_256: hash = sha256.New() default: return nil, errors.New("failed to generate key encrypter for RSA-OAEP: RSA_OAEP/RSA_OAEP_256 required") } encryp...
go
func (e RSAOAEPKeyEncrypt) KeyEncrypt(cek []byte) (ByteSource, error) { var hash hash.Hash switch e.alg { case jwa.RSA_OAEP: hash = sha1.New() case jwa.RSA_OAEP_256: hash = sha256.New() default: return nil, errors.New("failed to generate key encrypter for RSA-OAEP: RSA_OAEP/RSA_OAEP_256 required") } encryp...
[ "func", "(", "e", "RSAOAEPKeyEncrypt", ")", "KeyEncrypt", "(", "cek", "[", "]", "byte", ")", "(", "ByteSource", ",", "error", ")", "{", "var", "hash", "hash", ".", "Hash", "\n", "switch", "e", ".", "alg", "{", "case", "jwa", ".", "RSA_OAEP", ":", "...
// KeyEncrypt encrypts the content encryption key using RSA OAEP
[ "KeyEncrypt", "encrypts", "the", "content", "encryption", "key", "using", "RSA", "OAEP" ]
0251e8147021ce27b0d3b1812b7c07265fe7a538
https://github.com/lestrrat-go/jwx/blob/0251e8147021ce27b0d3b1812b7c07265fe7a538/jwe/key_encrypt.go#L227-L242