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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
153,500
op/go-libspotify
spotify/libspotify.go
IsAutoLinked
func (t *Track) IsAutoLinked() bool { linked := C.sp_track_is_autolinked( t.session.sp_session, t.sp_track, ) return linked == 1 }
go
func (t *Track) IsAutoLinked() bool { linked := C.sp_track_is_autolinked( t.session.sp_session, t.sp_track, ) return linked == 1 }
[ "func", "(", "t", "*", "Track", ")", "IsAutoLinked", "(", ")", "bool", "{", "linked", ":=", "C", ".", "sp_track_is_autolinked", "(", "t", ".", "session", ".", "sp_session", ",", "t", ".", "sp_track", ",", ")", "\n", "return", "linked", "==", "1", "\n...
// IsAutoLinked returns true if the track is auto-linked to another track.
[ "IsAutoLinked", "returns", "true", "if", "the", "track", "is", "auto", "-", "linked", "to", "another", "track", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1837-L1843
153,501
op/go-libspotify
spotify/libspotify.go
PlayableTrack
func (t *Track) PlayableTrack() *Track { sp_track := C.sp_track_get_playable( t.session.sp_session, t.sp_track, ) return newTrack(t.session, sp_track) }
go
func (t *Track) PlayableTrack() *Track { sp_track := C.sp_track_get_playable( t.session.sp_session, t.sp_track, ) return newTrack(t.session, sp_track) }
[ "func", "(", "t", "*", "Track", ")", "PlayableTrack", "(", ")", "*", "Track", "{", "sp_track", ":=", "C", ".", "sp_track_get_playable", "(", "t", ".", "session", ".", "sp_session", ",", "t", ".", "sp_track", ",", ")", "\n", "return", "newTrack", "(", ...
// PlayableTrack returns the track which is the actual track that will be // played if the given track is played.
[ "PlayableTrack", "returns", "the", "track", "which", "is", "the", "actual", "track", "that", "will", "be", "played", "if", "the", "given", "track", "is", "played", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1847-L1853
153,502
op/go-libspotify
spotify/libspotify.go
LinkOffset
func (t *Track) LinkOffset(offset time.Duration) *Link { offsetMs := C.int(offset / time.Millisecond) sp_link := C.sp_link_create_from_track(t.sp_track, offsetMs) return newLink(t.session, sp_link, false) }
go
func (t *Track) LinkOffset(offset time.Duration) *Link { offsetMs := C.int(offset / time.Millisecond) sp_link := C.sp_link_create_from_track(t.sp_track, offsetMs) return newLink(t.session, sp_link, false) }
[ "func", "(", "t", "*", "Track", ")", "LinkOffset", "(", "offset", "time", ".", "Duration", ")", "*", "Link", "{", "offsetMs", ":=", "C", ".", "int", "(", "offset", "/", "time", ".", "Millisecond", ")", "\n", "sp_link", ":=", "C", ".", "sp_link_create...
// Link returns a link object representing the track at the given offset.
[ "Link", "returns", "a", "link", "object", "representing", "the", "track", "at", "the", "given", "offset", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1874-L1878
153,503
op/go-libspotify
spotify/libspotify.go
IsStarred
func (t *Track) IsStarred() bool { starred := C.sp_track_is_starred( t.session.sp_session, t.sp_track, ) return starred == 1 }
go
func (t *Track) IsStarred() bool { starred := C.sp_track_is_starred( t.session.sp_session, t.sp_track, ) return starred == 1 }
[ "func", "(", "t", "*", "Track", ")", "IsStarred", "(", ")", "bool", "{", "starred", ":=", "C", ".", "sp_track_is_starred", "(", "t", ".", "session", ".", "sp_session", ",", "t", ".", "sp_track", ",", ")", "\n", "return", "starred", "==", "1", "\n", ...
// IsStarred returns true if the track is starred by the currently logged in // user.
[ "IsStarred", "returns", "true", "if", "the", "track", "is", "starred", "by", "the", "currently", "logged", "in", "user", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1882-L1888
153,504
op/go-libspotify
spotify/libspotify.go
Artist
func (t *Track) Artist(n int) *Artist { if n < 0 || n >= t.Artists() { panic("spotify: track artist index out of range") } sp_artist := C.sp_track_artist(t.sp_track, C.int(n)) return newArtist(t.session, sp_artist) }
go
func (t *Track) Artist(n int) *Artist { if n < 0 || n >= t.Artists() { panic("spotify: track artist index out of range") } sp_artist := C.sp_track_artist(t.sp_track, C.int(n)) return newArtist(t.session, sp_artist) }
[ "func", "(", "t", "*", "Track", ")", "Artist", "(", "n", "int", ")", "*", "Artist", "{", "if", "n", "<", "0", "||", "n", ">=", "t", ".", "Artists", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "sp_artist", ":=", "C", ".", ...
// Artist returns the artist on the specified index. Use Artists to know how // many artists that performed on the track.
[ "Artist", "returns", "the", "artist", "on", "the", "specified", "index", ".", "Use", "Artists", "to", "know", "how", "many", "artists", "that", "performed", "on", "the", "track", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1899-L1905
153,505
op/go-libspotify
spotify/libspotify.go
Album
func (t *Track) Album() *Album { sp_album := C.sp_track_album(t.sp_track) return newAlbum(t.session, sp_album) }
go
func (t *Track) Album() *Album { sp_album := C.sp_track_album(t.sp_track) return newAlbum(t.session, sp_album) }
[ "func", "(", "t", "*", "Track", ")", "Album", "(", ")", "*", "Album", "{", "sp_album", ":=", "C", ".", "sp_track_album", "(", "t", ".", "sp_track", ")", "\n", "return", "newAlbum", "(", "t", ".", "session", ",", "sp_album", ")", "\n", "}" ]
// Album returns the album of the track.
[ "Album", "returns", "the", "album", "of", "the", "track", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1908-L1911
153,506
op/go-libspotify
spotify/libspotify.go
Name
func (t *Track) Name() string { return C.GoString(C.sp_track_name(t.sp_track)) }
go
func (t *Track) Name() string { return C.GoString(C.sp_track_name(t.sp_track)) }
[ "func", "(", "t", "*", "Track", ")", "Name", "(", ")", "string", "{", "return", "C", ".", "GoString", "(", "C", ".", "sp_track_name", "(", "t", ".", "sp_track", ")", ")", "\n", "}" ]
// Name returns the track name.
[ "Name", "returns", "the", "track", "name", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1914-L1916
153,507
op/go-libspotify
spotify/libspotify.go
Duration
func (t *Track) Duration() time.Duration { ms := C.sp_track_duration(t.sp_track) return time.Duration(ms) * time.Millisecond }
go
func (t *Track) Duration() time.Duration { ms := C.sp_track_duration(t.sp_track) return time.Duration(ms) * time.Millisecond }
[ "func", "(", "t", "*", "Track", ")", "Duration", "(", ")", "time", ".", "Duration", "{", "ms", ":=", "C", ".", "sp_track_duration", "(", "t", ".", "sp_track", ")", "\n", "return", "time", ".", "Duration", "(", "ms", ")", "*", "time", ".", "Millisec...
// Duration returns the length of the current track.
[ "Duration", "returns", "the", "length", "of", "the", "current", "track", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1919-L1922
153,508
op/go-libspotify
spotify/libspotify.go
Popularity
func (t *Track) Popularity() Popularity { p := C.sp_track_popularity(t.sp_track) return Popularity(p) }
go
func (t *Track) Popularity() Popularity { p := C.sp_track_popularity(t.sp_track) return Popularity(p) }
[ "func", "(", "t", "*", "Track", ")", "Popularity", "(", ")", "Popularity", "{", "p", ":=", "C", ".", "sp_track_popularity", "(", "t", ".", "sp_track", ")", "\n", "return", "Popularity", "(", "p", ")", "\n", "}" ]
// Popularity returns the popularity for the track.
[ "Popularity", "returns", "the", "popularity", "for", "the", "track", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L1928-L1931
153,509
op/go-libspotify
spotify/libspotify.go
Link
func (a *Album) Link() *Link { sp_link := C.sp_link_create_from_album(a.sp_album) return newLink(a.session, sp_link, false) }
go
func (a *Album) Link() *Link { sp_link := C.sp_link_create_from_album(a.sp_album) return newLink(a.session, sp_link, false) }
[ "func", "(", "a", "*", "Album", ")", "Link", "(", ")", "*", "Link", "{", "sp_link", ":=", "C", ".", "sp_link_create_from_album", "(", "a", ".", "sp_album", ")", "\n", "return", "newLink", "(", "a", ".", "session", ",", "sp_link", ",", "false", ")", ...
// Link creates a link object from the album.
[ "Link", "creates", "a", "link", "object", "from", "the", "album", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2040-L2043
153,510
op/go-libspotify
spotify/libspotify.go
Name
func (a *Album) Name() string { return C.GoString(C.sp_album_name(a.sp_album)) }
go
func (a *Album) Name() string { return C.GoString(C.sp_album_name(a.sp_album)) }
[ "func", "(", "a", "*", "Album", ")", "Name", "(", ")", "string", "{", "return", "C", ".", "GoString", "(", "C", ".", "sp_album_name", "(", "a", ".", "sp_album", ")", ")", "\n", "}" ]
// Name returns the name of the album.
[ "Name", "returns", "the", "name", "of", "the", "album", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2078-L2080
153,511
op/go-libspotify
spotify/libspotify.go
Link
func (a *Artist) Link() *Link { sp_link := C.sp_link_create_from_artist(a.sp_artist) return newLink(a.session, sp_link, false) }
go
func (a *Artist) Link() *Link { sp_link := C.sp_link_create_from_artist(a.sp_artist) return newLink(a.session, sp_link, false) }
[ "func", "(", "a", "*", "Artist", ")", "Link", "(", ")", "*", "Link", "{", "sp_link", ":=", "C", ".", "sp_link_create_from_artist", "(", "a", ".", "sp_artist", ")", "\n", "return", "newLink", "(", "a", ".", "session", ",", "sp_link", ",", "false", ")"...
// Link creates a link object from the artist.
[ "Link", "creates", "a", "link", "object", "from", "the", "artist", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2140-L2143
153,512
op/go-libspotify
spotify/libspotify.go
Name
func (a *Artist) Name() string { return C.GoString(C.sp_artist_name(a.sp_artist)) }
go
func (a *Artist) Name() string { return C.GoString(C.sp_artist_name(a.sp_artist)) }
[ "func", "(", "a", "*", "Artist", ")", "Name", "(", ")", "string", "{", "return", "C", ".", "GoString", "(", "C", ".", "sp_artist_name", "(", "a", ".", "sp_artist", ")", ")", "\n", "}" ]
// Name returns the name of the artist.
[ "Name", "returns", "the", "name", "of", "the", "artist", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2146-L2148
153,513
op/go-libspotify
spotify/libspotify.go
CanonicalName
func (u *User) CanonicalName() string { return C.GoString(C.sp_user_canonical_name(u.sp_user)) }
go
func (u *User) CanonicalName() string { return C.GoString(C.sp_user_canonical_name(u.sp_user)) }
[ "func", "(", "u", "*", "User", ")", "CanonicalName", "(", ")", "string", "{", "return", "C", ".", "GoString", "(", "C", ".", "sp_user_canonical_name", "(", "u", ".", "sp_user", ")", ")", "\n", "}" ]
// CanonicalName returns the user's canonical username.
[ "CanonicalName", "returns", "the", "user", "s", "canonical", "username", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2229-L2231
153,514
op/go-libspotify
spotify/libspotify.go
DisplayName
func (u *User) DisplayName() string { return C.GoString(C.sp_user_display_name(u.sp_user)) }
go
func (u *User) DisplayName() string { return C.GoString(C.sp_user_display_name(u.sp_user)) }
[ "func", "(", "u", "*", "User", ")", "DisplayName", "(", ")", "string", "{", "return", "C", ".", "GoString", "(", "C", ".", "sp_user_display_name", "(", "u", ".", "sp_user", ")", ")", "\n", "}" ]
// DisplayName returns the user's displayable username.
[ "DisplayName", "returns", "the", "user", "s", "displayable", "username", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2249-L2251
153,515
op/go-libspotify
spotify/libspotify.go
SetAutolinkTracks
func (p *Playlist) SetAutolinkTracks(l bool) { C.sp_playlist_set_autolink_tracks(p.sp_playlist, cbool(l)) }
go
func (p *Playlist) SetAutolinkTracks(l bool) { C.sp_playlist_set_autolink_tracks(p.sp_playlist, cbool(l)) }
[ "func", "(", "p", "*", "Playlist", ")", "SetAutolinkTracks", "(", "l", "bool", ")", "{", "C", ".", "sp_playlist_set_autolink_tracks", "(", "p", ".", "sp_playlist", ",", "cbool", "(", "l", ")", ")", "\n", "}" ]
// SetAutolinkTracks sets the autolinking state for a playlist. // // If a playlist is autolinked, unplayable tracks will be made playable by // linking them to other Spotify tracks, where possible.
[ "SetAutolinkTracks", "sets", "the", "autolinking", "state", "for", "a", "playlist", ".", "If", "a", "playlist", "is", "autolinked", "unplayable", "tracks", "will", "be", "made", "playable", "by", "linking", "them", "to", "other", "Spotify", "tracks", "where", ...
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2377-L2379
153,516
op/go-libspotify
spotify/libspotify.go
User
func (pt *PlaylistTrack) User() *User { sp_user := C.sp_playlist_track_creator(pt.playlist.sp_playlist, C.int(pt.index)) return newUser(pt.playlist.session, sp_user) }
go
func (pt *PlaylistTrack) User() *User { sp_user := C.sp_playlist_track_creator(pt.playlist.sp_playlist, C.int(pt.index)) return newUser(pt.playlist.session, sp_user) }
[ "func", "(", "pt", "*", "PlaylistTrack", ")", "User", "(", ")", "*", "User", "{", "sp_user", ":=", "C", ".", "sp_playlist_track_creator", "(", "pt", ".", "playlist", ".", "sp_playlist", ",", "C", ".", "int", "(", "pt", ".", "index", ")", ")", "\n", ...
// User returns the user that added the track to the playlist.
[ "User", "returns", "the", "user", "that", "added", "the", "track", "to", "the", "playlist", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2447-L2450
153,517
op/go-libspotify
spotify/libspotify.go
Time
func (pt *PlaylistTrack) Time() time.Time { t := C.sp_playlist_track_create_time(pt.playlist.sp_playlist, C.int(pt.index)) return time.Unix(int64(t), 0) }
go
func (pt *PlaylistTrack) Time() time.Time { t := C.sp_playlist_track_create_time(pt.playlist.sp_playlist, C.int(pt.index)) return time.Unix(int64(t), 0) }
[ "func", "(", "pt", "*", "PlaylistTrack", ")", "Time", "(", ")", "time", ".", "Time", "{", "t", ":=", "C", ".", "sp_playlist_track_create_time", "(", "pt", ".", "playlist", ".", "sp_playlist", ",", "C", ".", "int", "(", "pt", ".", "index", ")", ")", ...
// Time returns the time when the track was added to the playlist.
[ "Time", "returns", "the", "time", "when", "the", "track", "was", "added", "to", "the", "playlist", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2453-L2456
153,518
op/go-libspotify
spotify/libspotify.go
Track
func (pt *PlaylistTrack) Track() *Track { // TODO return PlaylistTrack and add extra functionality on top of that sp_track := C.sp_playlist_track(pt.playlist.sp_playlist, C.int(pt.index)) return newTrack(pt.playlist.session, sp_track) }
go
func (pt *PlaylistTrack) Track() *Track { // TODO return PlaylistTrack and add extra functionality on top of that sp_track := C.sp_playlist_track(pt.playlist.sp_playlist, C.int(pt.index)) return newTrack(pt.playlist.session, sp_track) }
[ "func", "(", "pt", "*", "PlaylistTrack", ")", "Track", "(", ")", "*", "Track", "{", "// TODO return PlaylistTrack and add extra functionality on top of that", "sp_track", ":=", "C", ".", "sp_playlist_track", "(", "pt", ".", "playlist", ".", "sp_playlist", ",", "C", ...
// Track returns the track metadata object for the playlist entry.
[ "Track", "returns", "the", "track", "metadata", "object", "for", "the", "playlist", "entry", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2459-L2463
153,519
op/go-libspotify
spotify/libspotify.go
Seen
func (pt *PlaylistTrack) Seen() bool { seen := C.sp_playlist_track_seen(pt.playlist.sp_playlist, C.int(pt.index)) return seen == 1 }
go
func (pt *PlaylistTrack) Seen() bool { seen := C.sp_playlist_track_seen(pt.playlist.sp_playlist, C.int(pt.index)) return seen == 1 }
[ "func", "(", "pt", "*", "PlaylistTrack", ")", "Seen", "(", ")", "bool", "{", "seen", ":=", "C", ".", "sp_playlist_track_seen", "(", "pt", ".", "playlist", ".", "sp_playlist", ",", "C", ".", "int", "(", "pt", ".", "index", ")", ")", "\n", "return", ...
// Seen returns true if the entry has been marked as seen or not.
[ "Seen", "returns", "true", "if", "the", "entry", "has", "been", "marked", "as", "seen", "or", "not", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2466-L2469
153,520
op/go-libspotify
spotify/libspotify.go
SetSeen
func (pt *PlaylistTrack) SetSeen(seen bool) error { rc := C.sp_playlist_track_set_seen(pt.playlist.sp_playlist, C.int(pt.index), cbool(seen)) if rc != C.SP_ERROR_OK { return spError(rc) } return nil }
go
func (pt *PlaylistTrack) SetSeen(seen bool) error { rc := C.sp_playlist_track_set_seen(pt.playlist.sp_playlist, C.int(pt.index), cbool(seen)) if rc != C.SP_ERROR_OK { return spError(rc) } return nil }
[ "func", "(", "pt", "*", "PlaylistTrack", ")", "SetSeen", "(", "seen", "bool", ")", "error", "{", "rc", ":=", "C", ".", "sp_playlist_track_set_seen", "(", "pt", ".", "playlist", ".", "sp_playlist", ",", "C", ".", "int", "(", "pt", ".", "index", ")", "...
// SetSeen marks the playlist track item as seen or not.
[ "SetSeen", "marks", "the", "playlist", "track", "item", "as", "seen", "or", "not", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2472-L2478
153,521
op/go-libspotify
spotify/libspotify.go
NewToplistRegion
func NewToplistRegion(region string) (ToplistRegion, error) { if len(region) != 2 { return 0, errors.New("spotify: invalid toplist region") } region = strings.ToUpper(region) r := int(region[0])<<8 | int(region[1]) return ToplistRegion(r), nil }
go
func NewToplistRegion(region string) (ToplistRegion, error) { if len(region) != 2 { return 0, errors.New("spotify: invalid toplist region") } region = strings.ToUpper(region) r := int(region[0])<<8 | int(region[1]) return ToplistRegion(r), nil }
[ "func", "NewToplistRegion", "(", "region", "string", ")", "(", "ToplistRegion", ",", "error", ")", "{", "if", "len", "(", "region", ")", "!=", "2", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "region", "=",...
// NewToplistRegion returns the toplist region for a ISO // 3166-1 country code. // // Also see ToplistRegionEverywhere and ToplistRegionUser // for some special constants.
[ "NewToplistRegion", "returns", "the", "toplist", "region", "for", "a", "ISO", "3166", "-", "1", "country", "code", ".", "Also", "see", "ToplistRegionEverywhere", "and", "ToplistRegionUser", "for", "some", "special", "constants", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2519-L2526
153,522
op/go-libspotify
spotify/libspotify.go
newToplist
func newToplist(s *Session, ttype toplistType, r ToplistRegion, user *User) *toplist { var cusername *C.char if user != nil { cusername = C.CString(user.CanonicalName()) defer C.free(unsafe.Pointer(cusername)) } t := &toplist{session: s, ttype: ttype} t.wg.Add(1) t.sp_toplistbrowse = C.toplistbrowse_create( t.session.sp_session, C.sp_toplisttype(ttype), C.sp_toplistregion(r), cusername, unsafe.Pointer(t), ) runtime.SetFinalizer(t, (*toplist).release) return t }
go
func newToplist(s *Session, ttype toplistType, r ToplistRegion, user *User) *toplist { var cusername *C.char if user != nil { cusername = C.CString(user.CanonicalName()) defer C.free(unsafe.Pointer(cusername)) } t := &toplist{session: s, ttype: ttype} t.wg.Add(1) t.sp_toplistbrowse = C.toplistbrowse_create( t.session.sp_session, C.sp_toplisttype(ttype), C.sp_toplistregion(r), cusername, unsafe.Pointer(t), ) runtime.SetFinalizer(t, (*toplist).release) return t }
[ "func", "newToplist", "(", "s", "*", "Session", ",", "ttype", "toplistType", ",", "r", "ToplistRegion", ",", "user", "*", "User", ")", "*", "toplist", "{", "var", "cusername", "*", "C", ".", "char", "\n", "if", "user", "!=", "nil", "{", "cusername", ...
// newToplist creates a wrapper around the toplist object. If the user object // is nil, the global toplist for the region will be used. Both user and region // can be specified if the toplist for the user's region should be fetched.
[ "newToplist", "creates", "a", "wrapper", "around", "the", "toplist", "object", ".", "If", "the", "user", "object", "is", "nil", "the", "global", "toplist", "for", "the", "region", "will", "be", "used", ".", "Both", "user", "and", "region", "can", "be", "...
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2551-L2569
153,523
op/go-libspotify
spotify/libspotify.go
Duration
func (t *toplist) Duration() time.Duration { ms := C.sp_toplistbrowse_backend_request_duration(t.sp_toplistbrowse) if ms < 0 { ms = 0 } return time.Duration(ms) * time.Millisecond }
go
func (t *toplist) Duration() time.Duration { ms := C.sp_toplistbrowse_backend_request_duration(t.sp_toplistbrowse) if ms < 0 { ms = 0 } return time.Duration(ms) * time.Millisecond }
[ "func", "(", "t", "*", "toplist", ")", "Duration", "(", ")", "time", ".", "Duration", "{", "ms", ":=", "C", ".", "sp_toplistbrowse_backend_request_duration", "(", "t", ".", "sp_toplistbrowse", ")", "\n", "if", "ms", "<", "0", "{", "ms", "=", "0", "\n",...
// Duration returns the time spent waiting for // the Spotify backend to serve the toplist.
[ "Duration", "returns", "the", "time", "spent", "waiting", "for", "the", "Spotify", "backend", "to", "serve", "the", "toplist", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2595-L2601
153,524
op/go-libspotify
spotify/libspotify.go
Track
func (tt *TracksToplist) Track(n int) *Track { if n < 0 || n >= tt.Tracks() { panic("spotify: toplist track out of range") } sp_track := C.sp_toplistbrowse_track(tt.sp_toplistbrowse, C.int(n)) return newTrack(tt.session, sp_track) }
go
func (tt *TracksToplist) Track(n int) *Track { if n < 0 || n >= tt.Tracks() { panic("spotify: toplist track out of range") } sp_track := C.sp_toplistbrowse_track(tt.sp_toplistbrowse, C.int(n)) return newTrack(tt.session, sp_track) }
[ "func", "(", "tt", "*", "TracksToplist", ")", "Track", "(", "n", "int", ")", "*", "Track", "{", "if", "n", "<", "0", "||", "n", ">=", "tt", ".", "Tracks", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "sp_track", ":=", "C", ...
// Track returns the track given the index from the toplist.
[ "Track", "returns", "the", "track", "given", "the", "index", "from", "the", "toplist", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2662-L2668
153,525
op/go-libspotify
spotify/libspotify.go
Data
func (i *Image) Data() []byte { var size C.size_t var data unsafe.Pointer = C.sp_image_data(i.sp_image, &size) return C.GoBytes(data, C.int(size)) }
go
func (i *Image) Data() []byte { var size C.size_t var data unsafe.Pointer = C.sp_image_data(i.sp_image, &size) return C.GoBytes(data, C.int(size)) }
[ "func", "(", "i", "*", "Image", ")", "Data", "(", ")", "[", "]", "byte", "{", "var", "size", "C", ".", "size_t", "\n", "var", "data", "unsafe", ".", "Pointer", "=", "C", ".", "sp_image_data", "(", "i", ".", "sp_image", ",", "&", "size", ")", "\...
// Data returns the image data.
[ "Data", "returns", "the", "image", "data", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2747-L2751
153,526
op/go-libspotify
spotify/libspotify.go
Decode
func (i *Image) Decode() (image.Image, string, error) { data := i.Data() buffer := bytes.NewBuffer(data) return image.Decode(buffer) }
go
func (i *Image) Decode() (image.Image, string, error) { data := i.Data() buffer := bytes.NewBuffer(data) return image.Decode(buffer) }
[ "func", "(", "i", "*", "Image", ")", "Decode", "(", ")", "(", "image", ".", "Image", ",", "string", ",", "error", ")", "{", "data", ":=", "i", ".", "Data", "(", ")", "\n", "buffer", ":=", "bytes", ".", "NewBuffer", "(", "data", ")", "\n", "retu...
// Decode returns a decoded image and the format name used during format // registration.
[ "Decode", "returns", "a", "decoded", "image", "and", "the", "format", "name", "used", "during", "format", "registration", "." ]
12dd11fb33ecf760c356b65dc1116bc92589dea4
https://github.com/op/go-libspotify/blob/12dd11fb33ecf760c356b65dc1116bc92589dea4/spotify/libspotify.go#L2755-L2759
153,527
ONSdigital/go-ns
clients/clientlog/clientlog.go
Do
func Do(ctx context.Context, action, service, uri string, data ...log.Data) { d := log.Data{ "action": action, "uri": uri, } if len(data) == 0 { d["method"] = "GET" } else { for _, dat := range data { for k, v := range dat { d[k] = v } } } log.InfoCtx(ctx, fmt.Sprintf("Making request to service: %s", service), d) }
go
func Do(ctx context.Context, action, service, uri string, data ...log.Data) { d := log.Data{ "action": action, "uri": uri, } if len(data) == 0 { d["method"] = "GET" } else { for _, dat := range data { for k, v := range dat { d[k] = v } } } log.InfoCtx(ctx, fmt.Sprintf("Making request to service: %s", service), d) }
[ "func", "Do", "(", "ctx", "context", ".", "Context", ",", "action", ",", "service", ",", "uri", "string", ",", "data", "...", "log", ".", "Data", ")", "{", "d", ":=", "log", ".", "Data", "{", "\"", "\"", ":", "action", ",", "\"", "\"", ":", "ur...
// Do should be used by clients to log a request to a given service // before it is made. If no log.Data is given then the request type // is assumed to be GET
[ "Do", "should", "be", "used", "by", "clients", "to", "log", "a", "request", "to", "a", "given", "service", "before", "it", "is", "made", ".", "If", "no", "log", ".", "Data", "is", "given", "then", "the", "request", "type", "is", "assumed", "to", "be"...
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/clients/clientlog/clientlog.go#L13-L30
153,528
ONSdigital/go-ns
clients/importapi/importapi.go
GetImportJob
func (api *Client) GetImportJob(ctx context.Context, importJobID string) (ImportJob, bool, error) { var importJob ImportJob path := api.url + "/jobs/" + importJobID jsonBody, httpCode, err := api.getJSON(ctx, path, 0, nil) if httpCode == http.StatusNotFound { return importJob, false, nil } logData := log.Data{ "path": path, "importJobID": importJobID, "httpCode": httpCode, "jsonBody": string(jsonBody), } var isFatal bool if err == nil && httpCode != http.StatusOK { if httpCode < http.StatusInternalServerError { isFatal = true } err = errors.New("Bad response while getting import job") } else { isFatal = true } if err != nil { log.ErrorC("GetImportJob", err, logData) return importJob, isFatal, err } if err := json.Unmarshal(jsonBody, &importJob); err != nil { log.ErrorC("GetImportJob unmarshal", err, logData) return ImportJob{}, true, err } return importJob, false, nil }
go
func (api *Client) GetImportJob(ctx context.Context, importJobID string) (ImportJob, bool, error) { var importJob ImportJob path := api.url + "/jobs/" + importJobID jsonBody, httpCode, err := api.getJSON(ctx, path, 0, nil) if httpCode == http.StatusNotFound { return importJob, false, nil } logData := log.Data{ "path": path, "importJobID": importJobID, "httpCode": httpCode, "jsonBody": string(jsonBody), } var isFatal bool if err == nil && httpCode != http.StatusOK { if httpCode < http.StatusInternalServerError { isFatal = true } err = errors.New("Bad response while getting import job") } else { isFatal = true } if err != nil { log.ErrorC("GetImportJob", err, logData) return importJob, isFatal, err } if err := json.Unmarshal(jsonBody, &importJob); err != nil { log.ErrorC("GetImportJob unmarshal", err, logData) return ImportJob{}, true, err } return importJob, false, nil }
[ "func", "(", "api", "*", "Client", ")", "GetImportJob", "(", "ctx", "context", ".", "Context", ",", "importJobID", "string", ")", "(", "ImportJob", ",", "bool", ",", "error", ")", "{", "var", "importJob", "ImportJob", "\n", "path", ":=", "api", ".", "u...
// GetImportJob asks the Import API for the details for an Import job
[ "GetImportJob", "asks", "the", "Import", "API", "for", "the", "details", "for", "an", "Import", "job" ]
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/clients/importapi/importapi.go#L99-L133
153,529
ONSdigital/go-ns
clients/importapi/importapi.go
UpdateImportJobState
func (api *Client) UpdateImportJobState(ctx context.Context, jobID string, newState string) error { path := api.url + "/jobs/" + jobID jsonUpload := []byte(`{"state":"` + newState + `"}`) jsonResult, httpCode, err := api.putJSON(ctx, path, 0, jsonUpload) logData := log.Data{ "path": path, "importJobID": jobID, "jsonUpload": jsonUpload, "httpCode": httpCode, "jsonResult": jsonResult, } if err == nil && httpCode != http.StatusOK { err = errors.New("Bad HTTP response") } if err != nil { log.ErrorC("UpdateImportJobState", err, logData) return err } return nil }
go
func (api *Client) UpdateImportJobState(ctx context.Context, jobID string, newState string) error { path := api.url + "/jobs/" + jobID jsonUpload := []byte(`{"state":"` + newState + `"}`) jsonResult, httpCode, err := api.putJSON(ctx, path, 0, jsonUpload) logData := log.Data{ "path": path, "importJobID": jobID, "jsonUpload": jsonUpload, "httpCode": httpCode, "jsonResult": jsonResult, } if err == nil && httpCode != http.StatusOK { err = errors.New("Bad HTTP response") } if err != nil { log.ErrorC("UpdateImportJobState", err, logData) return err } return nil }
[ "func", "(", "api", "*", "Client", ")", "UpdateImportJobState", "(", "ctx", "context", ".", "Context", ",", "jobID", "string", ",", "newState", "string", ")", "error", "{", "path", ":=", "api", ".", "url", "+", "\"", "\"", "+", "jobID", "\n", "jsonUplo...
// UpdateImportJobState tells the Import API that the state has changed of an Import job
[ "UpdateImportJobState", "tells", "the", "Import", "API", "that", "the", "state", "has", "changed", "of", "an", "Import", "job" ]
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/clients/importapi/importapi.go#L136-L156
153,530
ONSdigital/go-ns
clients/importapi/importapi.go
NewAPIResponse
func NewAPIResponse(resp *http.Response, uri string) (e *ErrInvalidAPIResponse) { e = &ErrInvalidAPIResponse{ actualCode: resp.StatusCode, uri: uri, } if resp.StatusCode == http.StatusNotFound { body, err := getBody(resp) if err != nil { e.body = "Client failed to read response body" return } e.body = string(body) } return }
go
func NewAPIResponse(resp *http.Response, uri string) (e *ErrInvalidAPIResponse) { e = &ErrInvalidAPIResponse{ actualCode: resp.StatusCode, uri: uri, } if resp.StatusCode == http.StatusNotFound { body, err := getBody(resp) if err != nil { e.body = "Client failed to read response body" return } e.body = string(body) } return }
[ "func", "NewAPIResponse", "(", "resp", "*", "http", ".", "Response", ",", "uri", "string", ")", "(", "e", "*", "ErrInvalidAPIResponse", ")", "{", "e", "=", "&", "ErrInvalidAPIResponse", "{", "actualCode", ":", "resp", ".", "StatusCode", ",", "uri", ":", ...
// NewAPIResponse creates an error response, optionally adding body to e when status is 404
[ "NewAPIResponse", "creates", "an", "error", "response", "optionally", "adding", "body", "to", "e", "when", "status", "is", "404" ]
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/clients/importapi/importapi.go#L218-L232
153,531
hnakamur/zap-ltsv
config.go
RegisterLTSVEncoder
func RegisterLTSVEncoder() error { return zap.RegisterEncoder("ltsv", func(cfg zapcore.EncoderConfig) (zapcore.Encoder, error) { return NewLTSVEncoder(cfg), nil }) }
go
func RegisterLTSVEncoder() error { return zap.RegisterEncoder("ltsv", func(cfg zapcore.EncoderConfig) (zapcore.Encoder, error) { return NewLTSVEncoder(cfg), nil }) }
[ "func", "RegisterLTSVEncoder", "(", ")", "error", "{", "return", "zap", ".", "RegisterEncoder", "(", "\"", "\"", ",", "func", "(", "cfg", "zapcore", ".", "EncoderConfig", ")", "(", "zapcore", ".", "Encoder", ",", "error", ")", "{", "return", "NewLTSVEncode...
// RegisterLTSVEncoder registers the LTSV encoder.
[ "RegisterLTSVEncoder", "registers", "the", "LTSV", "encoder", "." ]
10a3dd1d839c3a7838fed08fe053fb5a8316d666
https://github.com/hnakamur/zap-ltsv/blob/10a3dd1d839c3a7838fed08fe053fb5a8316d666/config.go#L9-L14
153,532
hnakamur/zap-ltsv
config.go
NewProductionEncoderConfig
func NewProductionEncoderConfig() zapcore.EncoderConfig { return zapcore.EncoderConfig{ TimeKey: "time", LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", EncodeLevel: zapcore.LowercaseLevelEncoder, EncodeTime: zapcore.EpochTimeEncoder, EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, } }
go
func NewProductionEncoderConfig() zapcore.EncoderConfig { return zapcore.EncoderConfig{ TimeKey: "time", LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", EncodeLevel: zapcore.LowercaseLevelEncoder, EncodeTime: zapcore.EpochTimeEncoder, EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, } }
[ "func", "NewProductionEncoderConfig", "(", ")", "zapcore", ".", "EncoderConfig", "{", "return", "zapcore", ".", "EncoderConfig", "{", "TimeKey", ":", "\"", "\"", ",", "LevelKey", ":", "\"", "\"", ",", "NameKey", ":", "\"", "\"", ",", "CallerKey", ":", "\""...
// NewProductionEncoderConfig returns an opinionated EncoderConfig for // production environments.
[ "NewProductionEncoderConfig", "returns", "an", "opinionated", "EncoderConfig", "for", "production", "environments", "." ]
10a3dd1d839c3a7838fed08fe053fb5a8316d666
https://github.com/hnakamur/zap-ltsv/blob/10a3dd1d839c3a7838fed08fe053fb5a8316d666/config.go#L18-L31
153,533
hnakamur/zap-ltsv
config.go
NewProductionConfig
func NewProductionConfig() zap.Config { return zap.Config{ Level: zap.NewAtomicLevelAt(zap.InfoLevel), Development: false, Sampling: &zap.SamplingConfig{ Initial: 100, Thereafter: 100, }, Encoding: "ltsv", EncoderConfig: NewProductionEncoderConfig(), OutputPaths: []string{"stderr"}, ErrorOutputPaths: []string{"stderr"}, } }
go
func NewProductionConfig() zap.Config { return zap.Config{ Level: zap.NewAtomicLevelAt(zap.InfoLevel), Development: false, Sampling: &zap.SamplingConfig{ Initial: 100, Thereafter: 100, }, Encoding: "ltsv", EncoderConfig: NewProductionEncoderConfig(), OutputPaths: []string{"stderr"}, ErrorOutputPaths: []string{"stderr"}, } }
[ "func", "NewProductionConfig", "(", ")", "zap", ".", "Config", "{", "return", "zap", ".", "Config", "{", "Level", ":", "zap", ".", "NewAtomicLevelAt", "(", "zap", ".", "InfoLevel", ")", ",", "Development", ":", "false", ",", "Sampling", ":", "&", "zap", ...
// NewProductionConfig is the recommended production configuration. Logging is // enabled at InfoLevel and above. // // It uses a JSON encoder, writes to standard error, and enables sampling. // Stacktraces are automatically included on logs of ErrorLevel and above.
[ "NewProductionConfig", "is", "the", "recommended", "production", "configuration", ".", "Logging", "is", "enabled", "at", "InfoLevel", "and", "above", ".", "It", "uses", "a", "JSON", "encoder", "writes", "to", "standard", "error", "and", "enables", "sampling", "....
10a3dd1d839c3a7838fed08fe053fb5a8316d666
https://github.com/hnakamur/zap-ltsv/blob/10a3dd1d839c3a7838fed08fe053fb5a8316d666/config.go#L38-L51
153,534
hnakamur/zap-ltsv
config.go
NewDevelopmentEncoderConfig
func NewDevelopmentEncoderConfig() zapcore.EncoderConfig { return zapcore.EncoderConfig{ // Keys can be anything except the empty string. TimeKey: "time", LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", EncodeLevel: zapcore.LowercaseLevelEncoder, EncodeTime: zapcore.ISO8601TimeEncoder, EncodeDuration: zapcore.StringDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, } }
go
func NewDevelopmentEncoderConfig() zapcore.EncoderConfig { return zapcore.EncoderConfig{ // Keys can be anything except the empty string. TimeKey: "time", LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", EncodeLevel: zapcore.LowercaseLevelEncoder, EncodeTime: zapcore.ISO8601TimeEncoder, EncodeDuration: zapcore.StringDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, } }
[ "func", "NewDevelopmentEncoderConfig", "(", ")", "zapcore", ".", "EncoderConfig", "{", "return", "zapcore", ".", "EncoderConfig", "{", "// Keys can be anything except the empty string.", "TimeKey", ":", "\"", "\"", ",", "LevelKey", ":", "\"", "\"", ",", "NameKey", "...
// NewDevelopmentEncoderConfig returns an opinionated EncoderConfig for // development environments.
[ "NewDevelopmentEncoderConfig", "returns", "an", "opinionated", "EncoderConfig", "for", "development", "environments", "." ]
10a3dd1d839c3a7838fed08fe053fb5a8316d666
https://github.com/hnakamur/zap-ltsv/blob/10a3dd1d839c3a7838fed08fe053fb5a8316d666/config.go#L55-L69
153,535
ONSdigital/go-ns
s3/s3.go
New
func New(region string) (*S3, error) { // AWS credentials gathered from the env. auth, err := aws.GetAuth("", "", "", time.Time{}) if err != nil { return nil, err } s3 := s3.New(auth, aws.Regions[region]) return &S3{ s3, }, nil }
go
func New(region string) (*S3, error) { // AWS credentials gathered from the env. auth, err := aws.GetAuth("", "", "", time.Time{}) if err != nil { return nil, err } s3 := s3.New(auth, aws.Regions[region]) return &S3{ s3, }, nil }
[ "func", "New", "(", "region", "string", ")", "(", "*", "S3", ",", "error", ")", "{", "// AWS credentials gathered from the env.", "auth", ",", "err", ":=", "aws", ".", "GetAuth", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "time", ".", "T...
// New returns a new AWS specific file.Provider instance configured for the given region.
[ "New", "returns", "a", "new", "AWS", "specific", "file", ".", "Provider", "instance", "configured", "for", "the", "given", "region", "." ]
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/s3/s3.go#L16-L29
153,536
ONSdigital/go-ns
s3/s3.go
Get
func (s3 *S3) Get(rawURL string) (io.ReadCloser, error) { // Use the S3 URL implementation as the S3 drivers don't seem to handle fully qualified URLs that include the // bucket name. url, err := NewURL(rawURL) if err != nil { return nil, err } bucket := s3.Bucket(url.BucketName()) reader, err := bucket.GetReader(url.Path()) if err != nil { return nil, err } return reader, nil }
go
func (s3 *S3) Get(rawURL string) (io.ReadCloser, error) { // Use the S3 URL implementation as the S3 drivers don't seem to handle fully qualified URLs that include the // bucket name. url, err := NewURL(rawURL) if err != nil { return nil, err } bucket := s3.Bucket(url.BucketName()) reader, err := bucket.GetReader(url.Path()) if err != nil { return nil, err } return reader, nil }
[ "func", "(", "s3", "*", "S3", ")", "Get", "(", "rawURL", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "// Use the S3 URL implementation as the S3 drivers don't seem to handle fully qualified URLs that include the", "// bucket name.", "url", ",", ...
// Get an io.ReadCloser instance for the given fully qualified S3 URL.
[ "Get", "an", "io", ".", "ReadCloser", "instance", "for", "the", "given", "fully", "qualified", "S3", "URL", "." ]
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/s3/s3.go#L32-L48
153,537
ONSdigital/go-ns
avro/avro.go
Marshal
func (schema *Schema) Marshal(s interface{}) ([]byte, error) { v := reflect.ValueOf(s) if v.Kind() == reflect.PtrTo(reflect.TypeOf(s)).Kind() { v = reflect.Indirect(v) } // Only structs are supported so return an empty result if the passed object // isn't a struct. if v.Kind() != reflect.Struct { return nil, ErrUnsupportedType(v.Kind()) } // If a pointer to a struct is passed, get the type of the dereferenced object. typ := reflect.TypeOf(s) if typ.Kind() == reflect.Ptr { typ = typ.Elem() } // Check for unsupported interface types err := checkFieldType(v, typ) if err != nil { return nil, err } avroSchema, err := avro.ParseSchema(schema.Definition) if err != nil { return nil, err } record, err := getRecord(avroSchema, v, typ) if err != nil { return nil, err } writer := avro.NewGenericDatumWriter() writer.SetSchema(avroSchema) buffer := new(bytes.Buffer) encoder := avro.NewBinaryEncoder(buffer) err = writer.Write(record, encoder) if err != nil { return nil, err } return buffer.Bytes(), nil }
go
func (schema *Schema) Marshal(s interface{}) ([]byte, error) { v := reflect.ValueOf(s) if v.Kind() == reflect.PtrTo(reflect.TypeOf(s)).Kind() { v = reflect.Indirect(v) } // Only structs are supported so return an empty result if the passed object // isn't a struct. if v.Kind() != reflect.Struct { return nil, ErrUnsupportedType(v.Kind()) } // If a pointer to a struct is passed, get the type of the dereferenced object. typ := reflect.TypeOf(s) if typ.Kind() == reflect.Ptr { typ = typ.Elem() } // Check for unsupported interface types err := checkFieldType(v, typ) if err != nil { return nil, err } avroSchema, err := avro.ParseSchema(schema.Definition) if err != nil { return nil, err } record, err := getRecord(avroSchema, v, typ) if err != nil { return nil, err } writer := avro.NewGenericDatumWriter() writer.SetSchema(avroSchema) buffer := new(bytes.Buffer) encoder := avro.NewBinaryEncoder(buffer) err = writer.Write(record, encoder) if err != nil { return nil, err } return buffer.Bytes(), nil }
[ "func", "(", "schema", "*", "Schema", ")", "Marshal", "(", "s", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "v", ":=", "reflect", ".", "ValueOf", "(", "s", ")", "\n\n", "if", "v", ".", "Kind", "(", ")", "==", "r...
// Marshal is used to avro encode the interface of s.
[ "Marshal", "is", "used", "to", "avro", "encode", "the", "interface", "of", "s", "." ]
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/avro/avro.go#L33-L80
153,538
ONSdigital/go-ns
avro/avro.go
Unmarshal
func (schema *Schema) Unmarshal(message []byte, s interface{}) error { v := reflect.ValueOf(s) vp := reflect.ValueOf(s) if v.Kind() == reflect.PtrTo(reflect.TypeOf(s)).Kind() { v = reflect.Indirect(v) } // Only structs are supported so return an empty result if the passed object // isn't a struct. if v.Kind() != reflect.Struct { return ErrUnsupportedType(v.Kind()) } // If a pointer to a struct is passed, get the type of the dereferenced object. typ := reflect.TypeOf(s) if typ.Kind() == reflect.Ptr { typ = typ.Elem() } return populateStructFromSchema(schema.Definition, message, typ, v, vp) }
go
func (schema *Schema) Unmarshal(message []byte, s interface{}) error { v := reflect.ValueOf(s) vp := reflect.ValueOf(s) if v.Kind() == reflect.PtrTo(reflect.TypeOf(s)).Kind() { v = reflect.Indirect(v) } // Only structs are supported so return an empty result if the passed object // isn't a struct. if v.Kind() != reflect.Struct { return ErrUnsupportedType(v.Kind()) } // If a pointer to a struct is passed, get the type of the dereferenced object. typ := reflect.TypeOf(s) if typ.Kind() == reflect.Ptr { typ = typ.Elem() } return populateStructFromSchema(schema.Definition, message, typ, v, vp) }
[ "func", "(", "schema", "*", "Schema", ")", "Unmarshal", "(", "message", "[", "]", "byte", ",", "s", "interface", "{", "}", ")", "error", "{", "v", ":=", "reflect", ".", "ValueOf", "(", "s", ")", "\n", "vp", ":=", "reflect", ".", "ValueOf", "(", "...
// Unmarshal is used to parse the avro encoded data and store the // result in the value pointed to by s.
[ "Unmarshal", "is", "used", "to", "parse", "the", "avro", "encoded", "data", "and", "store", "the", "result", "in", "the", "value", "pointed", "to", "by", "s", "." ]
81b393bfc6e80674df603b7fde2f31a35e81b9dd
https://github.com/ONSdigital/go-ns/blob/81b393bfc6e80674df603b7fde2f31a35e81b9dd/avro/avro.go#L84-L105
153,539
alexkappa/mustache
lookup.go
lookup
func lookup(name string, context ...interface{}) (interface{}, bool) { // If the dot notation was used we split the word in two and perform two // consecutive lookups. If the first one fails we return no value and a // negative truth. Taken from github.com/hoisie/mustache. if name != "." && strings.Contains(name, ".") { parts := strings.SplitN(name, ".", 2) if value, ok := lookup(parts[0], context...); ok { return lookup(parts[1], value) } return nil, false } // Iterate over the context chain and try to match the name to a value. for _, c := range context { // Reflect on the value of the current context. reflectValue := reflect.ValueOf(c) // If the name is ".", we should return the whole context as-is. if name == "." { return c, truth(reflectValue) } switch reflectValue.Kind() { // If the current context is a map, we'll look for a key in that map // that matches the name. case reflect.Map: item := reflectValue.MapIndex(reflect.ValueOf(name)) if item.IsValid() { return item.Interface(), truth(item) } // If the current context is a struct, we'll look for a property in that // struct that matches the name. In the near future I'd like to add // support for matching struct names to tags so we can use lower_case // names in our templates which makes it more mustache like. case reflect.Struct: field := reflectValue.FieldByName(name) if field.IsValid() { return field.Interface(), truth(field) } method := reflectValue.MethodByName(name) if method.IsValid() && method.Type().NumIn() == 1 { out := method.Call(nil)[0] return out.Interface(), truth(out) } } // If by this point no value was matched, we'll move up a step in the // chain and try to match a value there. } // We've exhausted the whole context chain and found nothing. Return a nil // value and a negative truth. return nil, false }
go
func lookup(name string, context ...interface{}) (interface{}, bool) { // If the dot notation was used we split the word in two and perform two // consecutive lookups. If the first one fails we return no value and a // negative truth. Taken from github.com/hoisie/mustache. if name != "." && strings.Contains(name, ".") { parts := strings.SplitN(name, ".", 2) if value, ok := lookup(parts[0], context...); ok { return lookup(parts[1], value) } return nil, false } // Iterate over the context chain and try to match the name to a value. for _, c := range context { // Reflect on the value of the current context. reflectValue := reflect.ValueOf(c) // If the name is ".", we should return the whole context as-is. if name == "." { return c, truth(reflectValue) } switch reflectValue.Kind() { // If the current context is a map, we'll look for a key in that map // that matches the name. case reflect.Map: item := reflectValue.MapIndex(reflect.ValueOf(name)) if item.IsValid() { return item.Interface(), truth(item) } // If the current context is a struct, we'll look for a property in that // struct that matches the name. In the near future I'd like to add // support for matching struct names to tags so we can use lower_case // names in our templates which makes it more mustache like. case reflect.Struct: field := reflectValue.FieldByName(name) if field.IsValid() { return field.Interface(), truth(field) } method := reflectValue.MethodByName(name) if method.IsValid() && method.Type().NumIn() == 1 { out := method.Call(nil)[0] return out.Interface(), truth(out) } } // If by this point no value was matched, we'll move up a step in the // chain and try to match a value there. } // We've exhausted the whole context chain and found nothing. Return a nil // value and a negative truth. return nil, false }
[ "func", "lookup", "(", "name", "string", ",", "context", "...", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "// If the dot notation was used we split the word in two and perform two", "// consecutive lookups. If the first one fails we retu...
// The lookup function searches for a property that matches name within the // context chain. We first start from the first item in the context chain which // is the most likely to have the value we're looking for. If not found, we'll // move up the chain and repeat.
[ "The", "lookup", "function", "searches", "for", "a", "property", "that", "matches", "name", "within", "the", "context", "chain", ".", "We", "first", "start", "from", "the", "first", "item", "in", "the", "context", "chain", "which", "is", "the", "most", "li...
d29845f60a879542625ba65812ddfb99fd9b12b9
https://github.com/alexkappa/mustache/blob/d29845f60a879542625ba65812ddfb99fd9b12b9/lookup.go#L15-L64
153,540
alexkappa/mustache
lookup.go
truth
func truth(r reflect.Value) bool { out: switch r.Kind() { case reflect.Array, reflect.Slice: return r.Len() > 0 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return r.Int() > 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return r.Uint() > 0 case reflect.Float32, reflect.Float64: return r.Float() > 0 case reflect.String: return r.String() != "" case reflect.Bool: return r.Bool() case reflect.Ptr, reflect.Interface: r = r.Elem() goto out default: return r.Interface() != nil } }
go
func truth(r reflect.Value) bool { out: switch r.Kind() { case reflect.Array, reflect.Slice: return r.Len() > 0 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return r.Int() > 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return r.Uint() > 0 case reflect.Float32, reflect.Float64: return r.Float() > 0 case reflect.String: return r.String() != "" case reflect.Bool: return r.Bool() case reflect.Ptr, reflect.Interface: r = r.Elem() goto out default: return r.Interface() != nil } }
[ "func", "truth", "(", "r", "reflect", ".", "Value", ")", "bool", "{", "out", ":", "switch", "r", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Array", ",", "reflect", ".", "Slice", ":", "return", "r", ".", "Len", "(", ")", ">", "0", "\n"...
// The truth function will tell us if r is a truthy value or not. This is // important for sections as they will render their content based on the output // of this function. // // Zero values are considered falsy. For example an empty string, the integer 0 // and so on are all considered falsy.
[ "The", "truth", "function", "will", "tell", "us", "if", "r", "is", "a", "truthy", "value", "or", "not", ".", "This", "is", "important", "for", "sections", "as", "they", "will", "render", "their", "content", "based", "on", "the", "output", "of", "this", ...
d29845f60a879542625ba65812ddfb99fd9b12b9
https://github.com/alexkappa/mustache/blob/d29845f60a879542625ba65812ddfb99fd9b12b9/lookup.go#L72-L93
153,541
peter-edge/pkg-go
cobra/pkgcobra.go
RunFixedArgs
func RunFixedArgs(numArgs int, run func(args []string) error) func(*cobra.Command, []string) { return RunBoundedArgs(Bounds{Min: numArgs, Max: numArgs}, run) }
go
func RunFixedArgs(numArgs int, run func(args []string) error) func(*cobra.Command, []string) { return RunBoundedArgs(Bounds{Min: numArgs, Max: numArgs}, run) }
[ "func", "RunFixedArgs", "(", "numArgs", "int", ",", "run", "func", "(", "args", "[", "]", "string", ")", "error", ")", "func", "(", "*", "cobra", ".", "Command", ",", "[", "]", "string", ")", "{", "return", "RunBoundedArgs", "(", "Bounds", "{", "Min"...
// RunFixedArgs makes a new cobra run function that checks that the number of args is equal to numArgs.
[ "RunFixedArgs", "makes", "a", "new", "cobra", "run", "function", "that", "checks", "that", "the", "number", "of", "args", "is", "equal", "to", "numArgs", "." ]
318cf31141c87eaa4348bd8a54886ba3aaf2a427
https://github.com/peter-edge/pkg-go/blob/318cf31141c87eaa4348bd8a54886ba3aaf2a427/cobra/pkgcobra.go#L18-L20
153,542
peter-edge/pkg-go
cobra/pkgcobra.go
RunBoundedArgs
func RunBoundedArgs(argBounds Bounds, run func(args []string) error) func(*cobra.Command, []string) { return func(_ *cobra.Command, args []string) { Check(CheckBoundedArgs(argBounds, args)) Check(run(args)) } }
go
func RunBoundedArgs(argBounds Bounds, run func(args []string) error) func(*cobra.Command, []string) { return func(_ *cobra.Command, args []string) { Check(CheckBoundedArgs(argBounds, args)) Check(run(args)) } }
[ "func", "RunBoundedArgs", "(", "argBounds", "Bounds", ",", "run", "func", "(", "args", "[", "]", "string", ")", "error", ")", "func", "(", "*", "cobra", ".", "Command", ",", "[", "]", "string", ")", "{", "return", "func", "(", "_", "*", "cobra", "....
// RunBoundedArgs makes a new cobra run function that checks that the number of args is within argBounds.
[ "RunBoundedArgs", "makes", "a", "new", "cobra", "run", "function", "that", "checks", "that", "the", "number", "of", "args", "is", "within", "argBounds", "." ]
318cf31141c87eaa4348bd8a54886ba3aaf2a427
https://github.com/peter-edge/pkg-go/blob/318cf31141c87eaa4348bd8a54886ba3aaf2a427/cobra/pkgcobra.go#L23-L28
153,543
peter-edge/pkg-go
cobra/pkgcobra.go
Run
func Run(run func(args []string) error) func(*cobra.Command, []string) { return func(_ *cobra.Command, args []string) { Check(run(args)) } }
go
func Run(run func(args []string) error) func(*cobra.Command, []string) { return func(_ *cobra.Command, args []string) { Check(run(args)) } }
[ "func", "Run", "(", "run", "func", "(", "args", "[", "]", "string", ")", "error", ")", "func", "(", "*", "cobra", ".", "Command", ",", "[", "]", "string", ")", "{", "return", "func", "(", "_", "*", "cobra", ".", "Command", ",", "args", "[", "]"...
// Run makes a new cobra run function that wraps the given function.
[ "Run", "makes", "a", "new", "cobra", "run", "function", "that", "wraps", "the", "given", "function", "." ]
318cf31141c87eaa4348bd8a54886ba3aaf2a427
https://github.com/peter-edge/pkg-go/blob/318cf31141c87eaa4348bd8a54886ba3aaf2a427/cobra/pkgcobra.go#L31-L35
153,544
peter-edge/pkg-go
cobra/pkgcobra.go
CheckFixedArgs
func CheckFixedArgs(numArgs int, args []string) error { return CheckBoundedArgs(Bounds{Min: numArgs, Max: numArgs}, args) }
go
func CheckFixedArgs(numArgs int, args []string) error { return CheckBoundedArgs(Bounds{Min: numArgs, Max: numArgs}, args) }
[ "func", "CheckFixedArgs", "(", "numArgs", "int", ",", "args", "[", "]", "string", ")", "error", "{", "return", "CheckBoundedArgs", "(", "Bounds", "{", "Min", ":", "numArgs", ",", "Max", ":", "numArgs", "}", ",", "args", ")", "\n", "}" ]
// CheckFixedArgs checks that the number of arguments equals numArgs.
[ "CheckFixedArgs", "checks", "that", "the", "number", "of", "arguments", "equals", "numArgs", "." ]
318cf31141c87eaa4348bd8a54886ba3aaf2a427
https://github.com/peter-edge/pkg-go/blob/318cf31141c87eaa4348bd8a54886ba3aaf2a427/cobra/pkgcobra.go#L38-L40
153,545
peter-edge/pkg-go
cobra/pkgcobra.go
CheckBoundedArgs
func CheckBoundedArgs(argBounds Bounds, args []string) error { if argBounds.Min == 0 && argBounds.Max == 0 { if len(args) != 0 { return fmt.Errorf("Expected no args, got %d", len(args)) } return nil } if argBounds.Max == 0 { if len(args) < argBounds.Min { return fmt.Errorf("Expected at least %d args, got %d", argBounds.Min, len(args)) } return nil } if argBounds.Min == 0 { if len(args) > argBounds.Max { return fmt.Errorf("Expected at most %d args, got %d", argBounds.Max, len(args)) } return nil } if len(args) < argBounds.Min || len(args) > argBounds.Max { if argBounds.Min == argBounds.Max { return fmt.Errorf("Expected %d args, got %d", argBounds.Min, len(args)) } return fmt.Errorf("Expected between %d and %d args, got %d", argBounds.Min, argBounds.Max, len(args)) } return nil }
go
func CheckBoundedArgs(argBounds Bounds, args []string) error { if argBounds.Min == 0 && argBounds.Max == 0 { if len(args) != 0 { return fmt.Errorf("Expected no args, got %d", len(args)) } return nil } if argBounds.Max == 0 { if len(args) < argBounds.Min { return fmt.Errorf("Expected at least %d args, got %d", argBounds.Min, len(args)) } return nil } if argBounds.Min == 0 { if len(args) > argBounds.Max { return fmt.Errorf("Expected at most %d args, got %d", argBounds.Max, len(args)) } return nil } if len(args) < argBounds.Min || len(args) > argBounds.Max { if argBounds.Min == argBounds.Max { return fmt.Errorf("Expected %d args, got %d", argBounds.Min, len(args)) } return fmt.Errorf("Expected between %d and %d args, got %d", argBounds.Min, argBounds.Max, len(args)) } return nil }
[ "func", "CheckBoundedArgs", "(", "argBounds", "Bounds", ",", "args", "[", "]", "string", ")", "error", "{", "if", "argBounds", ".", "Min", "==", "0", "&&", "argBounds", ".", "Max", "==", "0", "{", "if", "len", "(", "args", ")", "!=", "0", "{", "ret...
// CheckBoundedArgs checks that the number of arguments is within the given Bounds.
[ "CheckBoundedArgs", "checks", "that", "the", "number", "of", "arguments", "is", "within", "the", "given", "Bounds", "." ]
318cf31141c87eaa4348bd8a54886ba3aaf2a427
https://github.com/peter-edge/pkg-go/blob/318cf31141c87eaa4348bd8a54886ba3aaf2a427/cobra/pkgcobra.go#L43-L69
153,546
peter-edge/pkg-go
metrics/pkgmetrics.go
SetupMetrics
func SetupMetrics(appName string, env Env) (metrics.Registry, error) { if env.StathatUserKey == "" && env.LibratoEmailAddress == "" && env.LibratoAPIToken == "" { return nil, nil } registry := metrics.NewPrefixedRegistry(appName) if env.StathatUserKey != "" { go stathat.Stathat( registry, time.Hour, env.StathatUserKey, ) } if env.LibratoEmailAddress != "" && env.LibratoAPIToken != "" { go librato.Librato( registry, 5*time.Minute, env.LibratoEmailAddress, env.LibratoAPIToken, appName, []float64{0.95}, time.Millisecond, ) } return registry, nil }
go
func SetupMetrics(appName string, env Env) (metrics.Registry, error) { if env.StathatUserKey == "" && env.LibratoEmailAddress == "" && env.LibratoAPIToken == "" { return nil, nil } registry := metrics.NewPrefixedRegistry(appName) if env.StathatUserKey != "" { go stathat.Stathat( registry, time.Hour, env.StathatUserKey, ) } if env.LibratoEmailAddress != "" && env.LibratoAPIToken != "" { go librato.Librato( registry, 5*time.Minute, env.LibratoEmailAddress, env.LibratoAPIToken, appName, []float64{0.95}, time.Millisecond, ) } return registry, nil }
[ "func", "SetupMetrics", "(", "appName", "string", ",", "env", "Env", ")", "(", "metrics", ".", "Registry", ",", "error", ")", "{", "if", "env", ".", "StathatUserKey", "==", "\"", "\"", "&&", "env", ".", "LibratoEmailAddress", "==", "\"", "\"", "&&", "e...
// SetupMetrics sets up metrics. // // The returned metrics.Registry can be nil.
[ "SetupMetrics", "sets", "up", "metrics", ".", "The", "returned", "metrics", ".", "Registry", "can", "be", "nil", "." ]
318cf31141c87eaa4348bd8a54886ba3aaf2a427
https://github.com/peter-edge/pkg-go/blob/318cf31141c87eaa4348bd8a54886ba3aaf2a427/metrics/pkgmetrics.go#L29-L53
153,547
drone/go-bitbucket
bitbucket/contents.go
Find
func (r *SourceResource) Find(owner, slug, revision, path string) (*Source, error) { src := Source{} url_path := fmt.Sprintf("/repositories/%s/%s/src/%s/%s", owner, slug, revision, path) if err := r.client.do("GET", url_path, nil, nil, &src); err != nil { return nil, err } return &src, nil }
go
func (r *SourceResource) Find(owner, slug, revision, path string) (*Source, error) { src := Source{} url_path := fmt.Sprintf("/repositories/%s/%s/src/%s/%s", owner, slug, revision, path) if err := r.client.do("GET", url_path, nil, nil, &src); err != nil { return nil, err } return &src, nil }
[ "func", "(", "r", "*", "SourceResource", ")", "Find", "(", "owner", ",", "slug", ",", "revision", ",", "path", "string", ")", "(", "*", "Source", ",", "error", ")", "{", "src", ":=", "Source", "{", "}", "\n", "url_path", ":=", "fmt", ".", "Sprintf"...
// Gets information about an individual file in a repository
[ "Gets", "information", "about", "an", "individual", "file", "in", "a", "repository" ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/contents.go#L23-L32
153,548
mkideal/log
provider/file.go
NewFile
func NewFile(opts string) logger.Provider { config := NewFileOpts() logger.UnmarshalOpts(opts, &config) config.setDefaults() return newFile(config) }
go
func NewFile(opts string) logger.Provider { config := NewFileOpts() logger.UnmarshalOpts(opts, &config) config.setDefaults() return newFile(config) }
[ "func", "NewFile", "(", "opts", "string", ")", "logger", ".", "Provider", "{", "config", ":=", "NewFileOpts", "(", ")", "\n", "logger", ".", "UnmarshalOpts", "(", "opts", ",", "&", "config", ")", "\n", "config", ".", "setDefaults", "(", ")", "\n", "ret...
// NewFile creates file provider
[ "NewFile", "creates", "file", "provider" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/provider/file.go#L74-L79
153,549
mkideal/log
provider/file.go
Write
func (p *File) Write(level logger.Level, headerLength int, data []byte) error { p.mu.Lock() defer p.mu.Unlock() if p.writer == nil { return errNilWriter } now := time.Now() if !isSameDay(now, p.createdTime) { if err := p.rotate(now); err != nil { return err } } n, err := p.writer.Write(data) p.written = true p.currentSize += n if p.currentSize >= p.config.MaxSize { p.rotate(now) } return err }
go
func (p *File) Write(level logger.Level, headerLength int, data []byte) error { p.mu.Lock() defer p.mu.Unlock() if p.writer == nil { return errNilWriter } now := time.Now() if !isSameDay(now, p.createdTime) { if err := p.rotate(now); err != nil { return err } } n, err := p.writer.Write(data) p.written = true p.currentSize += n if p.currentSize >= p.config.MaxSize { p.rotate(now) } return err }
[ "func", "(", "p", "*", "File", ")", "Write", "(", "level", "logger", ".", "Level", ",", "headerLength", "int", ",", "data", "[", "]", "byte", ")", "error", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock"...
// Write writes log to file
[ "Write", "writes", "log", "to", "file" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/provider/file.go#L102-L122
153,550
mkideal/log
provider/file.go
Close
func (p *File) Close() error { p.mu.Lock() defer p.mu.Unlock() return p.closeCurrent() }
go
func (p *File) Close() error { p.mu.Lock() defer p.mu.Unlock() return p.closeCurrent() }
[ "func", "(", "p", "*", "File", ")", "Close", "(", ")", "error", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "closeCurrent", "(", ")", "\n", "}" ]
// Close closes current log file
[ "Close", "closes", "current", "log", "file" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/provider/file.go#L137-L141
153,551
zaccone/spf
spf.go
CheckHostWithResolver
func CheckHostWithResolver(ip net.IP, domain, sender string, resolver Resolver) (Result, string, error) { /* * As per RFC 7208 Section 4.3: * If the <domain> is malformed (e.g., label longer than 63 * characters, zero-length label not at the end, etc.) or is not * a multi-label * domain name, [...], check_host() immediately returns None */ if !isDomainName(domain) { return None, "", ErrInvalidDomain } txts, err := resolver.LookupTXTStrict(NormalizeFQDN(domain)) switch err { case nil: // continue case ErrDNSLimitExceeded: return Permerror, "", err case ErrDNSPermerror: return None, "", err default: return Temperror, "", err } // If the resultant record set includes no records, check_host() // produces the "none" result. If the resultant record set includes // more than one record, check_host() produces the "permerror" result. spf, err := filterSPF(txts) if err != nil { return Permerror, "", err } if spf == "" { return None, "", ErrSPFNotFound } return newParser(sender, domain, ip, spf, resolver).parse() }
go
func CheckHostWithResolver(ip net.IP, domain, sender string, resolver Resolver) (Result, string, error) { /* * As per RFC 7208 Section 4.3: * If the <domain> is malformed (e.g., label longer than 63 * characters, zero-length label not at the end, etc.) or is not * a multi-label * domain name, [...], check_host() immediately returns None */ if !isDomainName(domain) { return None, "", ErrInvalidDomain } txts, err := resolver.LookupTXTStrict(NormalizeFQDN(domain)) switch err { case nil: // continue case ErrDNSLimitExceeded: return Permerror, "", err case ErrDNSPermerror: return None, "", err default: return Temperror, "", err } // If the resultant record set includes no records, check_host() // produces the "none" result. If the resultant record set includes // more than one record, check_host() produces the "permerror" result. spf, err := filterSPF(txts) if err != nil { return Permerror, "", err } if spf == "" { return None, "", ErrSPFNotFound } return newParser(sender, domain, ip, spf, resolver).parse() }
[ "func", "CheckHostWithResolver", "(", "ip", "net", ".", "IP", ",", "domain", ",", "sender", "string", ",", "resolver", "Resolver", ")", "(", "Result", ",", "string", ",", "error", ")", "{", "/*\n\t* As per RFC 7208 Section 4.3:\n\t* If the <domain> is malformed (e.g.,...
// CheckHostWithResolver allows using custom Resolver. // Note, that DNS lookup limits need to be enforced by provided Resolver. // // The function returns result of verification, explanations as result of "exp=", // and error as the reason for the encountered problem.
[ "CheckHostWithResolver", "allows", "using", "custom", "Resolver", ".", "Note", "that", "DNS", "lookup", "limits", "need", "to", "be", "enforced", "by", "provided", "Resolver", ".", "The", "function", "returns", "result", "of", "verification", "explanations", "as",...
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/spf.go#L131-L167
153,552
zaccone/spf
spf.go
filterSPF
func filterSPF(txt []string) (string, error) { const ( v = "v=spf1" vLen = 6 ) var ( spf string n int ) for _, s := range txt { if len(s) < vLen { continue } if len(s) == vLen { if s == v { spf = s n++ } continue } if s[vLen] != ' ' && s[vLen] != '\t' { continue } if !strings.HasPrefix(s, v) { continue } spf = s n++ } if n > 1 { return "", errTooManySPFRecords } return spf, nil }
go
func filterSPF(txt []string) (string, error) { const ( v = "v=spf1" vLen = 6 ) var ( spf string n int ) for _, s := range txt { if len(s) < vLen { continue } if len(s) == vLen { if s == v { spf = s n++ } continue } if s[vLen] != ' ' && s[vLen] != '\t' { continue } if !strings.HasPrefix(s, v) { continue } spf = s n++ } if n > 1 { return "", errTooManySPFRecords } return spf, nil }
[ "func", "filterSPF", "(", "txt", "[", "]", "string", ")", "(", "string", ",", "error", ")", "{", "const", "(", "v", "=", "\"", "\"", "\n", "vLen", "=", "6", "\n", ")", "\n", "var", "(", "spf", "string", "\n", "n", "int", "\n", ")", "\n\n", "f...
// Starting with the set of records that were returned by the lookup, // discard records that do not begin with a version section of exactly // "v=spf1". Note that the version section is terminated by either an // SP character or the end of the record. As an example, a record with // a version section of "v=spf10" does not match and is discarded.
[ "Starting", "with", "the", "set", "of", "records", "that", "were", "returned", "by", "the", "lookup", "discard", "records", "that", "do", "not", "begin", "with", "a", "version", "section", "of", "exactly", "v", "=", "spf1", ".", "Note", "that", "the", "v...
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/spf.go#L174-L208
153,553
drone/go-bitbucket
bitbucket/repos.go
List
func (r *RepoResource) List() ([]*Repo, error) { repos := []*Repo{} const path = "/user/repositories" if err := r.client.do("GET", path, nil, nil, &repos); err != nil { return nil, err } return repos, nil }
go
func (r *RepoResource) List() ([]*Repo, error) { repos := []*Repo{} const path = "/user/repositories" if err := r.client.do("GET", path, nil, nil, &repos); err != nil { return nil, err } return repos, nil }
[ "func", "(", "r", "*", "RepoResource", ")", "List", "(", ")", "(", "[", "]", "*", "Repo", ",", "error", ")", "{", "repos", ":=", "[", "]", "*", "Repo", "{", "}", "\n", "const", "path", "=", "\"", "\"", "\n\n", "if", "err", ":=", "r", ".", "...
// Gets the repositories owned by the individual or team account.
[ "Gets", "the", "repositories", "owned", "by", "the", "individual", "or", "team", "account", "." ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/repos.go#L39-L48
153,554
drone/go-bitbucket
bitbucket/repos.go
ListDashboard
func (r *RepoResource) ListDashboard() ([]*Account, error) { var m [][]interface{} const path = "/user/repositories/dashboard" if err := r.client.do("GET", path, nil, nil, &m); err != nil { return nil, err } return unmarshalAccounts(m), nil }
go
func (r *RepoResource) ListDashboard() ([]*Account, error) { var m [][]interface{} const path = "/user/repositories/dashboard" if err := r.client.do("GET", path, nil, nil, &m); err != nil { return nil, err } return unmarshalAccounts(m), nil }
[ "func", "(", "r", "*", "RepoResource", ")", "ListDashboard", "(", ")", "(", "[", "]", "*", "Account", ",", "error", ")", "{", "var", "m", "[", "]", "[", "]", "interface", "{", "}", "\n", "const", "path", "=", "\"", "\"", "\n\n", "if", "err", ":...
// Gets the repositories list from the account's dashboard.
[ "Gets", "the", "repositories", "list", "from", "the", "account", "s", "dashboard", "." ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/repos.go#L51-L60
153,555
drone/go-bitbucket
bitbucket/repos.go
ListDashboardRepos
func (r *RepoResource) ListDashboardRepos() ([]*Repo, error) { accounts, err := r.ListDashboard() if err != nil { return nil, nil } repos := []*Repo{} for _, acct := range accounts { repos = append(repos, acct.Repos...) } return repos, nil }
go
func (r *RepoResource) ListDashboardRepos() ([]*Repo, error) { accounts, err := r.ListDashboard() if err != nil { return nil, nil } repos := []*Repo{} for _, acct := range accounts { repos = append(repos, acct.Repos...) } return repos, nil }
[ "func", "(", "r", "*", "RepoResource", ")", "ListDashboardRepos", "(", ")", "(", "[", "]", "*", "Repo", ",", "error", ")", "{", "accounts", ",", "err", ":=", "r", ".", "ListDashboard", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil",...
// Gets the repositories list from the account's dashboard, and // converts the response to a list of Repos, instead of a // list of Accounts.
[ "Gets", "the", "repositories", "list", "from", "the", "account", "s", "dashboard", "and", "converts", "the", "response", "to", "a", "list", "of", "Repos", "instead", "of", "a", "list", "of", "Accounts", "." ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/repos.go#L65-L77
153,556
drone/go-bitbucket
bitbucket/repos.go
ListBranches
func (r *RepoResource) ListBranches(owner, slug string) ([]*Branch, error) { branchMap := map[string]*Branch{} path := fmt.Sprintf("/repositories/%s/%s/branches", owner, slug) if err := r.client.do("GET", path, nil, nil, &branchMap); err != nil { return nil, err } // The list is returned in a map ... // we really want a slice branches := []*Branch{} for _, branch := range branchMap { branches = append(branches, branch) } return branches, nil }
go
func (r *RepoResource) ListBranches(owner, slug string) ([]*Branch, error) { branchMap := map[string]*Branch{} path := fmt.Sprintf("/repositories/%s/%s/branches", owner, slug) if err := r.client.do("GET", path, nil, nil, &branchMap); err != nil { return nil, err } // The list is returned in a map ... // we really want a slice branches := []*Branch{} for _, branch := range branchMap { branches = append(branches, branch) } return branches, nil }
[ "func", "(", "r", "*", "RepoResource", ")", "ListBranches", "(", "owner", ",", "slug", "string", ")", "(", "[", "]", "*", "Branch", ",", "error", ")", "{", "branchMap", ":=", "map", "[", "string", "]", "*", "Branch", "{", "}", "\n", "path", ":=", ...
// Gets the list of Branches for the repository
[ "Gets", "the", "list", "of", "Branches", "for", "the", "repository" ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/repos.go#L80-L96
153,557
drone/go-bitbucket
bitbucket/repos.go
ListUser
func (r *RepoResource) ListUser(owner string) ([]*Repo, error) { repos := []*Repo{} path := fmt.Sprintf("/repositories/%s", owner) if err := r.client.do("GET", path, nil, nil, &repos); err != nil { return nil, err } return repos, nil }
go
func (r *RepoResource) ListUser(owner string) ([]*Repo, error) { repos := []*Repo{} path := fmt.Sprintf("/repositories/%s", owner) if err := r.client.do("GET", path, nil, nil, &repos); err != nil { return nil, err } return repos, nil }
[ "func", "(", "r", "*", "RepoResource", ")", "ListUser", "(", "owner", "string", ")", "(", "[", "]", "*", "Repo", ",", "error", ")", "{", "repos", ":=", "[", "]", "*", "Repo", "{", "}", "\n", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"",...
// Gets the repositories list for the named user.
[ "Gets", "the", "repositories", "list", "for", "the", "named", "user", "." ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/repos.go#L99-L108
153,558
mkideal/log
logger/logger.go
LogWith
func (l *withLogger) LogWith(level Level, calldepth int, data []byte, format string, args ...interface{}) { if l.GetLevel() >= level { l.output(level, calldepth, data, format, args...) } }
go
func (l *withLogger) LogWith(level Level, calldepth int, data []byte, format string, args ...interface{}) { if l.GetLevel() >= level { l.output(level, calldepth, data, format, args...) } }
[ "func", "(", "l", "*", "withLogger", ")", "LogWith", "(", "level", "Level", ",", "calldepth", "int", ",", "data", "[", "]", "byte", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "GetLevel", "(", ")", ...
// LogWith implements With interface
[ "LogWith", "implements", "With", "interface" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/logger/logger.go#L144-L148
153,559
edeckers/auroradnsclient
requests/requestor.go
NewAuroraRequestor
func NewAuroraRequestor(endpoint string, userID string, key string) (*AuroraRequestor, error) { if endpoint == "" { return nil, fmt.Errorf("Aurora endpoint missing") } if userID == "" || key == "" { return nil, fmt.Errorf("Aurora credentials missing") } return &AuroraRequestor{endpoint: endpoint, userID: userID, key: key}, nil }
go
func NewAuroraRequestor(endpoint string, userID string, key string) (*AuroraRequestor, error) { if endpoint == "" { return nil, fmt.Errorf("Aurora endpoint missing") } if userID == "" || key == "" { return nil, fmt.Errorf("Aurora credentials missing") } return &AuroraRequestor{endpoint: endpoint, userID: userID, key: key}, nil }
[ "func", "NewAuroraRequestor", "(", "endpoint", "string", ",", "userID", "string", ",", "key", "string", ")", "(", "*", "AuroraRequestor", ",", "error", ")", "{", "if", "endpoint", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", ...
// NewAuroraRequestor instantiates a new requestor
[ "NewAuroraRequestor", "instantiates", "a", "new", "requestor" ]
1563e622aaca0a8bb895a448f31d4a430ab97586
https://github.com/edeckers/auroradnsclient/blob/1563e622aaca0a8bb895a448f31d4a430ab97586/requests/requestor.go#L25-L35
153,560
edeckers/auroradnsclient
requests/requestor.go
Request
func (requestor *AuroraRequestor) Request(relativeURL string, method string, body []byte) ([]byte, error) { req, err := requestor.buildRequest(relativeURL, method, body) client := http.Client{Timeout: 30 * time.Second} resp, err := client.Do(req) if err != nil { logrus.Errorf("Failed request: %s", err) return nil, err } defer resp.Body.Close() rawResponse, err := httputil.DumpResponse(resp, true) logrus.Debugf("Received raw response:\n%s", rawResponse) if err != nil { logrus.Errorf("Failed to dump response: %s", err) } response, err := ioutil.ReadAll(resp.Body) if err != nil { logrus.Errorf("Failed to read response: %s", response) return nil, err } response, err = requestor.testInvalidResponse(resp, response) if err != nil { return nil, err } return response, nil }
go
func (requestor *AuroraRequestor) Request(relativeURL string, method string, body []byte) ([]byte, error) { req, err := requestor.buildRequest(relativeURL, method, body) client := http.Client{Timeout: 30 * time.Second} resp, err := client.Do(req) if err != nil { logrus.Errorf("Failed request: %s", err) return nil, err } defer resp.Body.Close() rawResponse, err := httputil.DumpResponse(resp, true) logrus.Debugf("Received raw response:\n%s", rawResponse) if err != nil { logrus.Errorf("Failed to dump response: %s", err) } response, err := ioutil.ReadAll(resp.Body) if err != nil { logrus.Errorf("Failed to read response: %s", response) return nil, err } response, err = requestor.testInvalidResponse(resp, response) if err != nil { return nil, err } return response, nil }
[ "func", "(", "requestor", "*", "AuroraRequestor", ")", "Request", "(", "relativeURL", "string", ",", "method", "string", ",", "body", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "req", ",", "err", ":=", "requestor", ".", "bu...
// Request builds and executues a request to the API
[ "Request", "builds", "and", "executues", "a", "request", "to", "the", "API" ]
1563e622aaca0a8bb895a448f31d4a430ab97586
https://github.com/edeckers/auroradnsclient/blob/1563e622aaca0a8bb895a448f31d4a430ab97586/requests/requestor.go#L94-L124
153,561
mkideal/log
log.go
InitWithLogger
func InitWithLogger(l logger.Logger) error { glogger.Quit() glogger = l glogger.Run() return nil }
go
func InitWithLogger(l logger.Logger) error { glogger.Quit() glogger = l glogger.Run() return nil }
[ "func", "InitWithLogger", "(", "l", "logger", ".", "Logger", ")", "error", "{", "glogger", ".", "Quit", "(", ")", "\n", "glogger", "=", "l", "\n", "glogger", ".", "Run", "(", ")", "\n", "return", "nil", "\n", "}" ]
// InitWithLogger inits global logger with a specified logger
[ "InitWithLogger", "inits", "global", "logger", "with", "a", "specified", "logger" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/log.go#L46-L51
153,562
mkideal/log
log.go
InitFileAndConsole
func InitFileAndConsole(fullpath string, toStderrLevel logger.Level) error { fileOpts := makeFileOpts(fullpath) consoleOpts := makeConsoleOpts(toStderrLevel) p := provider.NewMixProvider(provider.NewFile(fileOpts), provider.NewConsole(consoleOpts)) return InitWithProvider(p) }
go
func InitFileAndConsole(fullpath string, toStderrLevel logger.Level) error { fileOpts := makeFileOpts(fullpath) consoleOpts := makeConsoleOpts(toStderrLevel) p := provider.NewMixProvider(provider.NewFile(fileOpts), provider.NewConsole(consoleOpts)) return InitWithProvider(p) }
[ "func", "InitFileAndConsole", "(", "fullpath", "string", ",", "toStderrLevel", "logger", ".", "Level", ")", "error", "{", "fileOpts", ":=", "makeFileOpts", "(", "fullpath", ")", "\n", "consoleOpts", ":=", "makeConsoleOpts", "(", "toStderrLevel", ")", "\n", "p", ...
// InitFileAndConsole inits with console and file providers
[ "InitFileAndConsole", "inits", "with", "console", "and", "file", "providers" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/log.go#L141-L146
153,563
mkideal/log
log.go
InitMultiFileAndConsole
func InitMultiFileAndConsole(rootdir, filename string, toStderrLevel logger.Level) error { multifileOpts := makeMultiFileOpts(rootdir, filename) consoleOpts := makeConsoleOpts(toStderrLevel) p := provider.NewMixProvider(provider.NewMultiFile(multifileOpts), provider.NewConsole(consoleOpts)) return InitWithProvider(p) }
go
func InitMultiFileAndConsole(rootdir, filename string, toStderrLevel logger.Level) error { multifileOpts := makeMultiFileOpts(rootdir, filename) consoleOpts := makeConsoleOpts(toStderrLevel) p := provider.NewMixProvider(provider.NewMultiFile(multifileOpts), provider.NewConsole(consoleOpts)) return InitWithProvider(p) }
[ "func", "InitMultiFileAndConsole", "(", "rootdir", ",", "filename", "string", ",", "toStderrLevel", "logger", ".", "Level", ")", "error", "{", "multifileOpts", ":=", "makeMultiFileOpts", "(", "rootdir", ",", "filename", ")", "\n", "consoleOpts", ":=", "makeConsole...
// InitMultiFileAndConsole inits with console and multifile providers
[ "InitMultiFileAndConsole", "inits", "with", "console", "and", "multifile", "providers" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/log.go#L158-L163
153,564
mkideal/log
log.go
HTTPHandlerGetLevel
func HTTPHandlerGetLevel() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { io.WriteString(w, GetLevel().String()) }) }
go
func HTTPHandlerGetLevel() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { io.WriteString(w, GetLevel().String()) }) }
[ "func", "HTTPHandlerGetLevel", "(", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "io", ".", "WriteString", "(", "w", ",", ...
// HTTPHandlerGetLevel returns a http handler for getting log level
[ "HTTPHandlerGetLevel", "returns", "a", "http", "handler", "for", "getting", "log", "level" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/log.go#L213-L217
153,565
mkideal/log
log.go
HTTPHandlerSetLevel
func HTTPHandlerSetLevel() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.ParseForm() level := r.FormValue("level") lv, ok := ParseLevel(level) // invalid parameter if !ok { w.WriteHeader(http.StatusBadRequest) io.WriteString(w, "invalid log level: "+level) return } // not modified oldLevel := GetLevel() if lv == oldLevel { w.WriteHeader(http.StatusNotModified) io.WriteString(w, oldLevel.String()) return } // updated SetLevel(lv) io.WriteString(w, oldLevel.String()) }) }
go
func HTTPHandlerSetLevel() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.ParseForm() level := r.FormValue("level") lv, ok := ParseLevel(level) // invalid parameter if !ok { w.WriteHeader(http.StatusBadRequest) io.WriteString(w, "invalid log level: "+level) return } // not modified oldLevel := GetLevel() if lv == oldLevel { w.WriteHeader(http.StatusNotModified) io.WriteString(w, oldLevel.String()) return } // updated SetLevel(lv) io.WriteString(w, oldLevel.String()) }) }
[ "func", "HTTPHandlerSetLevel", "(", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "r", ".", "ParseForm", "(", ")", "\n", ...
// HTTPHandlerSetLevel sets new log level and returns old log level // Returns status code `StatusBadRequest` if parse log level fail
[ "HTTPHandlerSetLevel", "sets", "new", "log", "level", "and", "returns", "old", "log", "level", "Returns", "status", "code", "StatusBadRequest", "if", "parse", "log", "level", "fail" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/log.go#L221-L243
153,566
mkideal/log
log.go
With
func With(values ...interface{}) ContextLogger { if len(values) == 1 { return &contextLogger{isTrue: true, data: values[0]} } return &contextLogger{isTrue: true, data: values} }
go
func With(values ...interface{}) ContextLogger { if len(values) == 1 { return &contextLogger{isTrue: true, data: values[0]} } return &contextLogger{isTrue: true, data: values} }
[ "func", "With", "(", "values", "...", "interface", "{", "}", ")", "ContextLogger", "{", "if", "len", "(", "values", ")", "==", "1", "{", "return", "&", "contextLogger", "{", "isTrue", ":", "true", ",", "data", ":", "values", "[", "0", "]", "}", "\n...
// With returns a ContextLogger
[ "With", "returns", "a", "ContextLogger" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/log.go#L263-L268
153,567
mkideal/log
log.go
WithJSON
func WithJSON(values ...interface{}) ContextLogger { if len(values) == 1 { return &contextLogger{isTrue: true, data: values[0], formatter: jsonFormatter} } return &contextLogger{isTrue: true, data: values, formatter: jsonFormatter} }
go
func WithJSON(values ...interface{}) ContextLogger { if len(values) == 1 { return &contextLogger{isTrue: true, data: values[0], formatter: jsonFormatter} } return &contextLogger{isTrue: true, data: values, formatter: jsonFormatter} }
[ "func", "WithJSON", "(", "values", "...", "interface", "{", "}", ")", "ContextLogger", "{", "if", "len", "(", "values", ")", "==", "1", "{", "return", "&", "contextLogger", "{", "isTrue", ":", "true", ",", "data", ":", "values", "[", "0", "]", ",", ...
// WithJSON returns a ContextLogger using JSONFormatter
[ "WithJSON", "returns", "a", "ContextLogger", "using", "JSONFormatter" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/log.go#L271-L276
153,568
holys/safe
safe.go
New
func New(ml, mf, mt int, level Level) *Safety { return &Safety{ml, mf, mt, level} }
go
func New(ml, mf, mt int, level Level) *Safety { return &Safety{ml, mf, mt, level} }
[ "func", "New", "(", "ml", ",", "mf", ",", "mt", "int", ",", "level", "Level", ")", "*", "Safety", "{", "return", "&", "Safety", "{", "ml", ",", "mf", ",", "mt", ",", "level", "}", "\n", "}" ]
// New returns a Safety object.
[ "New", "returns", "a", "Safety", "object", "." ]
40a1d599da1188d48a032f27ac6ae1e38d79caee
https://github.com/holys/safe/blob/40a1d599da1188d48a032f27ac6ae1e38d79caee/safe.go#L51-L53
153,569
holys/safe
safe.go
Check
func (s *Safety) Check(raw string) Level { l := len([]rune(raw)) if l < s.ml { return Terrible } if s.isAsdf(raw) || s.isByStep(raw) { return Simple } if s.isCommonPassword(raw, s.mf) { return Simple } typ := 0 if lower.MatchString(raw) { typ++ } if upper.MatchString(raw) { typ++ } if number.MatchString(raw) { typ++ } if marks.MatchString(raw) { typ++ } if l < 8 && typ == 2 { return Simple } if typ < s.mt { return Medium } return Strong }
go
func (s *Safety) Check(raw string) Level { l := len([]rune(raw)) if l < s.ml { return Terrible } if s.isAsdf(raw) || s.isByStep(raw) { return Simple } if s.isCommonPassword(raw, s.mf) { return Simple } typ := 0 if lower.MatchString(raw) { typ++ } if upper.MatchString(raw) { typ++ } if number.MatchString(raw) { typ++ } if marks.MatchString(raw) { typ++ } if l < 8 && typ == 2 { return Simple } if typ < s.mt { return Medium } return Strong }
[ "func", "(", "s", "*", "Safety", ")", "Check", "(", "raw", "string", ")", "Level", "{", "l", ":=", "len", "(", "[", "]", "rune", "(", "raw", ")", ")", "\n", "if", "l", "<", "s", ".", "ml", "{", "return", "Terrible", "\n", "}", "\n\n", "if", ...
// Check validate the password, and get the level.
[ "Check", "validate", "the", "password", "and", "get", "the", "level", "." ]
40a1d599da1188d48a032f27ac6ae1e38d79caee
https://github.com/holys/safe/blob/40a1d599da1188d48a032f27ac6ae1e38d79caee/safe.go#L71-L109
153,570
holys/safe
safe.go
isAsdf
func (s *Safety) isAsdf(raw string) bool { // s in asdf , or reverse in asdf rev := reverse(raw) return strings.Contains(asdf, raw) || strings.Contains(asdf, rev) }
go
func (s *Safety) isAsdf(raw string) bool { // s in asdf , or reverse in asdf rev := reverse(raw) return strings.Contains(asdf, raw) || strings.Contains(asdf, rev) }
[ "func", "(", "s", "*", "Safety", ")", "isAsdf", "(", "raw", "string", ")", "bool", "{", "// s in asdf , or reverse in asdf", "rev", ":=", "reverse", "(", "raw", ")", "\n", "return", "strings", ".", "Contains", "(", "asdf", ",", "raw", ")", "||", "strings...
// If the password is in the order on keyboard.
[ "If", "the", "password", "is", "in", "the", "order", "on", "keyboard", "." ]
40a1d599da1188d48a032f27ac6ae1e38d79caee
https://github.com/holys/safe/blob/40a1d599da1188d48a032f27ac6ae1e38d79caee/safe.go#L112-L116
153,571
holys/safe
safe.go
isByStep
func (s *Safety) isByStep(raw string) bool { r := []rune(raw) delta := r[1] - r[0] for i, _ := range r { if i == 0 { continue } if r[i]-r[i-1] != delta { return false } } return true }
go
func (s *Safety) isByStep(raw string) bool { r := []rune(raw) delta := r[1] - r[0] for i, _ := range r { if i == 0 { continue } if r[i]-r[i-1] != delta { return false } } return true }
[ "func", "(", "s", "*", "Safety", ")", "isByStep", "(", "raw", "string", ")", "bool", "{", "r", ":=", "[", "]", "rune", "(", "raw", ")", "\n", "delta", ":=", "r", "[", "1", "]", "-", "r", "[", "0", "]", "\n\n", "for", "i", ",", "_", ":=", ...
// If the password is alphabet step by step.
[ "If", "the", "password", "is", "alphabet", "step", "by", "step", "." ]
40a1d599da1188d48a032f27ac6ae1e38d79caee
https://github.com/holys/safe/blob/40a1d599da1188d48a032f27ac6ae1e38d79caee/safe.go#L119-L133
153,572
mkideal/log
if_logger.go
With
func (il IfLogger) With(values ...interface{}) ContextLogger { if len(values) == 1 { return &contextLogger{isTrue: il.ok(), data: values[0]} } return &contextLogger{isTrue: il.ok(), data: values} }
go
func (il IfLogger) With(values ...interface{}) ContextLogger { if len(values) == 1 { return &contextLogger{isTrue: il.ok(), data: values[0]} } return &contextLogger{isTrue: il.ok(), data: values} }
[ "func", "(", "il", "IfLogger", ")", "With", "(", "values", "...", "interface", "{", "}", ")", "ContextLogger", "{", "if", "len", "(", "values", ")", "==", "1", "{", "return", "&", "contextLogger", "{", "isTrue", ":", "il", ".", "ok", "(", ")", ",",...
// With implements Context.With method
[ "With", "implements", "Context", ".", "With", "method" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/if_logger.go#L33-L38
153,573
mkideal/log
if_logger.go
WithJSON
func (il IfLogger) WithJSON(values ...interface{}) ContextLogger { return il.With(values...).SetFormatter(jsonFormatter) }
go
func (il IfLogger) WithJSON(values ...interface{}) ContextLogger { return il.With(values...).SetFormatter(jsonFormatter) }
[ "func", "(", "il", "IfLogger", ")", "WithJSON", "(", "values", "...", "interface", "{", "}", ")", "ContextLogger", "{", "return", "il", ".", "With", "(", "values", "...", ")", ".", "SetFormatter", "(", "jsonFormatter", ")", "\n", "}" ]
// WithJSON implements Context.WithJSON method
[ "WithJSON", "implements", "Context", ".", "WithJSON", "method" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/if_logger.go#L41-L43
153,574
mkideal/log
if_logger.go
SetFormatter
func (il IfLogger) SetFormatter(f Formatter) ContextLogger { return &contextLogger{ isTrue: il.ok(), formatter: f, } }
go
func (il IfLogger) SetFormatter(f Formatter) ContextLogger { return &contextLogger{ isTrue: il.ok(), formatter: f, } }
[ "func", "(", "il", "IfLogger", ")", "SetFormatter", "(", "f", "Formatter", ")", "ContextLogger", "{", "return", "&", "contextLogger", "{", "isTrue", ":", "il", ".", "ok", "(", ")", ",", "formatter", ":", "f", ",", "}", "\n", "}" ]
// SetFormatter implements Context.SetFormatter method
[ "SetFormatter", "implements", "Context", ".", "SetFormatter", "method" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/if_logger.go#L46-L51
153,575
mkideal/log
logger/log_level.go
String
func (level Level) String() string { switch level { case FATAL: return "FATAL" case ERROR: return "ERROR" case WARN: return "WARN" case INFO: return "INFO" case DEBUG: return "DEBUG" case TRACE: return "TRACE" } return "INVALID" }
go
func (level Level) String() string { switch level { case FATAL: return "FATAL" case ERROR: return "ERROR" case WARN: return "WARN" case INFO: return "INFO" case DEBUG: return "DEBUG" case TRACE: return "TRACE" } return "INVALID" }
[ "func", "(", "level", "Level", ")", "String", "(", ")", "string", "{", "switch", "level", "{", "case", "FATAL", ":", "return", "\"", "\"", "\n", "case", "ERROR", ":", "return", "\"", "\"", "\n", "case", "WARN", ":", "return", "\"", "\"", "\n", "cas...
// String returns a serialized string of level
[ "String", "returns", "a", "serialized", "string", "of", "level" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/logger/log_level.go#L48-L64
153,576
mkideal/log
logger/log_level.go
ParseLevel
func ParseLevel(s string) (lv Level, ok bool) { s = strings.ToUpper(s) switch s { case "FATAL", "F", FATAL.Literal(): return FATAL, true case "ERROR", "E", ERROR.Literal(): return ERROR, true case "WARN", "W", WARN.Literal(): return WARN, true case "INFO", "I", INFO.Literal(): return INFO, true case "DEBUG", "D", DEBUG.Literal(): return DEBUG, true case "TRACE", "T", TRACE.Literal(): return TRACE, true } return INFO, false }
go
func ParseLevel(s string) (lv Level, ok bool) { s = strings.ToUpper(s) switch s { case "FATAL", "F", FATAL.Literal(): return FATAL, true case "ERROR", "E", ERROR.Literal(): return ERROR, true case "WARN", "W", WARN.Literal(): return WARN, true case "INFO", "I", INFO.Literal(): return INFO, true case "DEBUG", "D", DEBUG.Literal(): return DEBUG, true case "TRACE", "T", TRACE.Literal(): return TRACE, true } return INFO, false }
[ "func", "ParseLevel", "(", "s", "string", ")", "(", "lv", "Level", ",", "ok", "bool", ")", "{", "s", "=", "strings", ".", "ToUpper", "(", "s", ")", "\n", "switch", "s", "{", "case", "\"", "\"", ",", "\"", "\"", ",", "FATAL", ".", "Literal", "("...
// ParseLevel parses log level from string
[ "ParseLevel", "parses", "log", "level", "from", "string" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/logger/log_level.go#L91-L108
153,577
mkideal/log
logger/log_level.go
MustParseLevel
func MustParseLevel(s string) Level { lv, ok := ParseLevel(s) if !ok { panic(ErrUnrecognizedLogLevel.Error() + ": " + s) } return lv }
go
func MustParseLevel(s string) Level { lv, ok := ParseLevel(s) if !ok { panic(ErrUnrecognizedLogLevel.Error() + ": " + s) } return lv }
[ "func", "MustParseLevel", "(", "s", "string", ")", "Level", "{", "lv", ",", "ok", ":=", "ParseLevel", "(", "s", ")", "\n", "if", "!", "ok", "{", "panic", "(", "ErrUnrecognizedLogLevel", ".", "Error", "(", ")", "+", "\"", "\"", "+", "s", ")", "\n", ...
// MustParseLevel similars to ParseLevel, but panic if parse failed
[ "MustParseLevel", "similars", "to", "ParseLevel", "but", "panic", "if", "parse", "failed" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/logger/log_level.go#L111-L117
153,578
edeckers/auroradnsclient
zones.go
GetZones
func (client *AuroraDNSClient) GetZones() ([]zones.ZoneRecord, error) { logrus.Debugf("GetZones") response, err := client.requestor.Request("zones", "GET", []byte("")) if err != nil { logrus.Errorf("Failed to get zones: %s", err) return nil, err } var respData []zones.ZoneRecord err = json.Unmarshal(response, &respData) if err != nil { logrus.Errorf("Failed to unmarshall response: %s", err) return nil, err } logrus.Debugf("Unmarshalled response: %+v", respData) return respData, nil }
go
func (client *AuroraDNSClient) GetZones() ([]zones.ZoneRecord, error) { logrus.Debugf("GetZones") response, err := client.requestor.Request("zones", "GET", []byte("")) if err != nil { logrus.Errorf("Failed to get zones: %s", err) return nil, err } var respData []zones.ZoneRecord err = json.Unmarshal(response, &respData) if err != nil { logrus.Errorf("Failed to unmarshall response: %s", err) return nil, err } logrus.Debugf("Unmarshalled response: %+v", respData) return respData, nil }
[ "func", "(", "client", "*", "AuroraDNSClient", ")", "GetZones", "(", ")", "(", "[", "]", "zones", ".", "ZoneRecord", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n", "response", ",", "err", ":=", "client", ".", "requestor"...
// GetZones returns a list of all zones
[ "GetZones", "returns", "a", "list", "of", "all", "zones" ]
1563e622aaca0a8bb895a448f31d4a430ab97586
https://github.com/edeckers/auroradnsclient/blob/1563e622aaca0a8bb895a448f31d4a430ab97586/zones.go#L11-L29
153,579
zaccone/spf
macro.go
parseMacro
func parseMacro(p *parser, input string) (string, error) { m := newMacro(input) var err error for m.state = scanText; m.state != nil; { m.state, err = m.state(m, p) if err != nil { // log error return "", err } } return strings.Join(m.output, ""), nil }
go
func parseMacro(p *parser, input string) (string, error) { m := newMacro(input) var err error for m.state = scanText; m.state != nil; { m.state, err = m.state(m, p) if err != nil { // log error return "", err } } return strings.Join(m.output, ""), nil }
[ "func", "parseMacro", "(", "p", "*", "parser", ",", "input", "string", ")", "(", "string", ",", "error", ")", "{", "m", ":=", "newMacro", "(", "input", ")", "\n", "var", "err", "error", "\n", "for", "m", ".", "state", "=", "scanText", ";", "m", "...
// parseMacro evaluates whole input string and replaces keywords with appropriate // values from
[ "parseMacro", "evaluates", "whole", "input", "string", "and", "replaces", "keywords", "with", "appropriate", "values", "from" ]
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/macro.go#L38-L50
153,580
zaccone/spf
macro.go
parseMacroToken
func parseMacroToken(p *parser, t *token) (string, error) { return parseMacro(p, t.value) }
go
func parseMacroToken(p *parser, t *token) (string, error) { return parseMacro(p, t.value) }
[ "func", "parseMacroToken", "(", "p", "*", "parser", ",", "t", "*", "token", ")", "(", "string", ",", "error", ")", "{", "return", "parseMacro", "(", "p", ",", "t", ".", "value", ")", "\n", "}" ]
// parseMacroToken evaluates whole input string and replaces keywords with appropriate // values from
[ "parseMacroToken", "evaluates", "whole", "input", "string", "and", "replaces", "keywords", "with", "appropriate", "values", "from" ]
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/macro.go#L54-L56
153,581
drone/go-bitbucket
bitbucket/teams.go
List
func (r *TeamResource) List() ([]*Team, error) { // we'll get the data in a key/value struct data := struct { Teams map[string]string }{ } data.Teams = map[string]string{} teams := []*Team{} if err := r.client.do("GET", "/user/privileges", nil, nil, &data); err != nil { return nil, err } for k,v := range data.Teams { team := &Team{ k, v } teams = append(teams, team) } return teams, nil }
go
func (r *TeamResource) List() ([]*Team, error) { // we'll get the data in a key/value struct data := struct { Teams map[string]string }{ } data.Teams = map[string]string{} teams := []*Team{} if err := r.client.do("GET", "/user/privileges", nil, nil, &data); err != nil { return nil, err } for k,v := range data.Teams { team := &Team{ k, v } teams = append(teams, team) } return teams, nil }
[ "func", "(", "r", "*", "TeamResource", ")", "List", "(", ")", "(", "[", "]", "*", "Team", ",", "error", ")", "{", "// we'll get the data in a key/value struct", "data", ":=", "struct", "{", "Teams", "map", "[", "string", "]", "string", "\n", "}", "{", ...
// Gets the groups with account privileges defined for a team account.
[ "Gets", "the", "groups", "with", "account", "privileges", "defined", "for", "a", "team", "account", "." ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/teams.go#L29-L49
153,582
mkideal/log
provider/console.go
NewConsoleWithWriter
func NewConsoleWithWriter(opts string, stdout, stderr io.Writer) logger.Provider { config := NewConsoleOpts() logger.UnmarshalOpts(opts, &config) return &Console{ config: config, stdout: stdout, stderr: stderr, } }
go
func NewConsoleWithWriter(opts string, stdout, stderr io.Writer) logger.Provider { config := NewConsoleOpts() logger.UnmarshalOpts(opts, &config) return &Console{ config: config, stdout: stdout, stderr: stderr, } }
[ "func", "NewConsoleWithWriter", "(", "opts", "string", ",", "stdout", ",", "stderr", "io", ".", "Writer", ")", "logger", ".", "Provider", "{", "config", ":=", "NewConsoleOpts", "(", ")", "\n", "logger", ".", "UnmarshalOpts", "(", "opts", ",", "&", "config"...
// NewConsoleWithWriter creates a console provider by specified writers
[ "NewConsoleWithWriter", "creates", "a", "console", "provider", "by", "specified", "writers" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/provider/console.go#L37-L45
153,583
mkideal/log
provider/mix.go
NewMixProvider
func NewMixProvider(first logger.Provider, others ...logger.Provider) logger.Provider { p := new(mixProvider) p.providers = make([]logger.Provider, 0, len(others)+1) p.providers = append(p.providers, first) for _, other := range others { p.providers = append(p.providers, other) } return p }
go
func NewMixProvider(first logger.Provider, others ...logger.Provider) logger.Provider { p := new(mixProvider) p.providers = make([]logger.Provider, 0, len(others)+1) p.providers = append(p.providers, first) for _, other := range others { p.providers = append(p.providers, other) } return p }
[ "func", "NewMixProvider", "(", "first", "logger", ".", "Provider", ",", "others", "...", "logger", ".", "Provider", ")", "logger", ".", "Provider", "{", "p", ":=", "new", "(", "mixProvider", ")", "\n", "p", ".", "providers", "=", "make", "(", "[", "]",...
// NewMixProvider creates a mixProvider
[ "NewMixProvider", "creates", "a", "mixProvider" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/provider/mix.go#L12-L20
153,584
mkideal/log
provider/mix.go
Write
func (p *mixProvider) Write(level logger.Level, headerLength int, data []byte) error { var err errorList for _, op := range p.providers { err.tryPush(op.Write(level, headerLength, data)) } return err.err() }
go
func (p *mixProvider) Write(level logger.Level, headerLength int, data []byte) error { var err errorList for _, op := range p.providers { err.tryPush(op.Write(level, headerLength, data)) } return err.err() }
[ "func", "(", "p", "*", "mixProvider", ")", "Write", "(", "level", "logger", ".", "Level", ",", "headerLength", "int", ",", "data", "[", "]", "byte", ")", "error", "{", "var", "err", "errorList", "\n", "for", "_", ",", "op", ":=", "range", "p", ".",...
// Write writes log to all inner providers
[ "Write", "writes", "log", "to", "all", "inner", "providers" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/provider/mix.go#L23-L29
153,585
mkideal/log
provider/mix.go
Close
func (p *mixProvider) Close() error { var err errorList for _, op := range p.providers { err.tryPush(op.Close()) } return err.err() }
go
func (p *mixProvider) Close() error { var err errorList for _, op := range p.providers { err.tryPush(op.Close()) } return err.err() }
[ "func", "(", "p", "*", "mixProvider", ")", "Close", "(", ")", "error", "{", "var", "err", "errorList", "\n", "for", "_", ",", "op", ":=", "range", "p", ".", "providers", "{", "err", ".", "tryPush", "(", "op", ".", "Close", "(", ")", ")", "\n", ...
// Close close all inner providers
[ "Close", "close", "all", "inner", "providers" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/provider/mix.go#L32-L38
153,586
drone/go-bitbucket
bitbucket/bitbucket.go
New
func New(consumerKey, consumerSecret, accessToken, tokenSecret string) *Client { c := &Client{} c.ConsumerKey = consumerKey c.ConsumerSecret = consumerSecret c.AccessToken = accessToken c.TokenSecret = tokenSecret c.Keys = &KeyResource{c} c.Repos = &RepoResource{c} c.Users = &UserResource{c} c.Emails = &EmailResource{c} c.Brokers = &BrokerResource{c} c.Teams = &TeamResource{c} c.RepoKeys = &RepoKeyResource{c} c.Sources = &SourceResource{c} return c }
go
func New(consumerKey, consumerSecret, accessToken, tokenSecret string) *Client { c := &Client{} c.ConsumerKey = consumerKey c.ConsumerSecret = consumerSecret c.AccessToken = accessToken c.TokenSecret = tokenSecret c.Keys = &KeyResource{c} c.Repos = &RepoResource{c} c.Users = &UserResource{c} c.Emails = &EmailResource{c} c.Brokers = &BrokerResource{c} c.Teams = &TeamResource{c} c.RepoKeys = &RepoKeyResource{c} c.Sources = &SourceResource{c} return c }
[ "func", "New", "(", "consumerKey", ",", "consumerSecret", ",", "accessToken", ",", "tokenSecret", "string", ")", "*", "Client", "{", "c", ":=", "&", "Client", "{", "}", "\n", "c", ".", "ConsumerKey", "=", "consumerKey", "\n", "c", ".", "ConsumerSecret", ...
// New creates an instance of the Bitbucket Client
[ "New", "creates", "an", "instance", "of", "the", "Bitbucket", "Client" ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/bitbucket.go#L12-L28
153,587
mkideal/log
logger/provider.go
Register
func Register(providerType string, creator ProviderCreator) { providersMu.Lock() defer providersMu.Unlock() if _, ok := providers[providerType]; ok { panic("provider " + providerType + " registered") } providers[providerType] = creator }
go
func Register(providerType string, creator ProviderCreator) { providersMu.Lock() defer providersMu.Unlock() if _, ok := providers[providerType]; ok { panic("provider " + providerType + " registered") } providers[providerType] = creator }
[ "func", "Register", "(", "providerType", "string", ",", "creator", "ProviderCreator", ")", "{", "providersMu", ".", "Lock", "(", ")", "\n", "defer", "providersMu", ".", "Unlock", "(", ")", "\n", "if", "_", ",", "ok", ":=", "providers", "[", "providerType",...
// Register registers a provider by name and creator
[ "Register", "registers", "a", "provider", "by", "name", "and", "creator" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/logger/provider.go#L26-L33
153,588
mkideal/log
logger/provider.go
Lookup
func Lookup(providerType string) ProviderCreator { providersMu.Lock() defer providersMu.Unlock() return providers[providerType] }
go
func Lookup(providerType string) ProviderCreator { providersMu.Lock() defer providersMu.Unlock() return providers[providerType] }
[ "func", "Lookup", "(", "providerType", "string", ")", "ProviderCreator", "{", "providersMu", ".", "Lock", "(", ")", "\n", "defer", "providersMu", ".", "Unlock", "(", ")", "\n", "return", "providers", "[", "providerType", "]", "\n", "}" ]
// Lookup gets provider creator by name
[ "Lookup", "gets", "provider", "creator", "by", "name" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/logger/provider.go#L36-L40
153,589
mkideal/log
logger/provider.go
UnmarshalOpts
func UnmarshalOpts(opts string, v interface{}) error { opts = strings.TrimSpace(opts) if opts == "" { return nil } if opts[0] != '[' && opts[0] != '{' { jsonString, err := form2JSON(opts) if err != nil { return err } opts = jsonString } return json.Unmarshal([]byte(opts), v) }
go
func UnmarshalOpts(opts string, v interface{}) error { opts = strings.TrimSpace(opts) if opts == "" { return nil } if opts[0] != '[' && opts[0] != '{' { jsonString, err := form2JSON(opts) if err != nil { return err } opts = jsonString } return json.Unmarshal([]byte(opts), v) }
[ "func", "UnmarshalOpts", "(", "opts", "string", ",", "v", "interface", "{", "}", ")", "error", "{", "opts", "=", "strings", ".", "TrimSpace", "(", "opts", ")", "\n", "if", "opts", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "if", "opts...
// UnmarshalOpts unmarshal JSON string opts to object v
[ "UnmarshalOpts", "unmarshal", "JSON", "string", "opts", "to", "object", "v" ]
df09d4873c0a3b93cb2630f4fce5baf2d68b65d5
https://github.com/mkideal/log/blob/df09d4873c0a3b93cb2630f4fce5baf2d68b65d5/logger/provider.go#L43-L56
153,590
zaccone/spf
resolver_limited.go
NewLimitedResolver
func NewLimitedResolver(r Resolver, lookupLimit, mxQueriesLimit uint16) Resolver { return &LimitedResolver{ lookupLimit: int32(lookupLimit), // sure that l is positive or zero mxQueriesLimit: mxQueriesLimit, resolver: r, } }
go
func NewLimitedResolver(r Resolver, lookupLimit, mxQueriesLimit uint16) Resolver { return &LimitedResolver{ lookupLimit: int32(lookupLimit), // sure that l is positive or zero mxQueriesLimit: mxQueriesLimit, resolver: r, } }
[ "func", "NewLimitedResolver", "(", "r", "Resolver", ",", "lookupLimit", ",", "mxQueriesLimit", "uint16", ")", "Resolver", "{", "return", "&", "LimitedResolver", "{", "lookupLimit", ":", "int32", "(", "lookupLimit", ")", ",", "// sure that l is positive or zero", "mx...
// NewLimitedResolver returns a resolver which will pass up to lookupLimit calls to r. // In addition to that limit, the evaluation of each "MX" record will be limited // to mxQueryLimit. // All calls over the limit will return ErrDNSLimitExceeded.
[ "NewLimitedResolver", "returns", "a", "resolver", "which", "will", "pass", "up", "to", "lookupLimit", "calls", "to", "r", ".", "In", "addition", "to", "that", "limit", "the", "evaluation", "of", "each", "MX", "record", "will", "be", "limited", "to", "mxQuery...
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/resolver_limited.go#L20-L26
153,591
zaccone/spf
resolver_limited.go
LookupTXT
func (r *LimitedResolver) LookupTXT(name string) ([]string, error) { if !r.canLookup() { return nil, ErrDNSLimitExceeded } return r.resolver.LookupTXT(name) }
go
func (r *LimitedResolver) LookupTXT(name string) ([]string, error) { if !r.canLookup() { return nil, ErrDNSLimitExceeded } return r.resolver.LookupTXT(name) }
[ "func", "(", "r", "*", "LimitedResolver", ")", "LookupTXT", "(", "name", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "!", "r", ".", "canLookup", "(", ")", "{", "return", "nil", ",", "ErrDNSLimitExceeded", "\n", "}", "\n", ...
// LookupTXT returns the DNS TXT records for the given domain name. // Returns nil and ErrDNSLimitExceeded if total number of lookups made // by underlying resolver exceed the limit.
[ "LookupTXT", "returns", "the", "DNS", "TXT", "records", "for", "the", "given", "domain", "name", ".", "Returns", "nil", "and", "ErrDNSLimitExceeded", "if", "total", "number", "of", "lookups", "made", "by", "underlying", "resolver", "exceed", "the", "limit", "....
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/resolver_limited.go#L35-L40
153,592
drone/go-bitbucket
bitbucket/users.go
Current
func (r *UserResource) Current() (*Account, error) { user := Account{} if err := r.client.do("GET", "/user", nil, nil, &user); err != nil { return nil, err } return &user, nil }
go
func (r *UserResource) Current() (*Account, error) { user := Account{} if err := r.client.do("GET", "/user", nil, nil, &user); err != nil { return nil, err } return &user, nil }
[ "func", "(", "r", "*", "UserResource", ")", "Current", "(", ")", "(", "*", "Account", ",", "error", ")", "{", "user", ":=", "Account", "{", "}", "\n", "if", "err", ":=", "r", ".", "client", ".", "do", "(", "\"", "\"", ",", "\"", "\"", ",", "n...
// Gets the basic information associated with an account and a list // of all its repositories both public and private.
[ "Gets", "the", "basic", "information", "associated", "with", "an", "account", "and", "a", "list", "of", "all", "its", "repositories", "both", "public", "and", "private", "." ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/users.go#L32-L39
153,593
drone/go-bitbucket
bitbucket/users.go
Find
func (r *UserResource) Find(username string) (*Account, error) { user := Account{} path := fmt.Sprintf("/users/%s", username) if err := r.client.do("GET", path, nil, nil, &user); err != nil { return nil, err } return &user, nil }
go
func (r *UserResource) Find(username string) (*Account, error) { user := Account{} path := fmt.Sprintf("/users/%s", username) if err := r.client.do("GET", path, nil, nil, &user); err != nil { return nil, err } return &user, nil }
[ "func", "(", "r", "*", "UserResource", ")", "Find", "(", "username", "string", ")", "(", "*", "Account", ",", "error", ")", "{", "user", ":=", "Account", "{", "}", "\n", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "username", ")", ...
// Gets the basic information associated with the specified user // account.
[ "Gets", "the", "basic", "information", "associated", "with", "the", "specified", "user", "account", "." ]
ba761238e76830e4d552e84bc526d08b12af05cd
https://github.com/drone/go-bitbucket/blob/ba761238e76830e4d552e84bc526d08b12af05cd/bitbucket/users.go#L43-L52
153,594
zaccone/spf
lexer.go
lex
func lex(input string) []*token { var tokens []*token l := &lexer{0, 0, 0, len(input), input} for { token := l.scan() if token.mechanism == tEOF { break } tokens = append(tokens, token) } return tokens }
go
func lex(input string) []*token { var tokens []*token l := &lexer{0, 0, 0, len(input), input} for { token := l.scan() if token.mechanism == tEOF { break } tokens = append(tokens, token) } return tokens }
[ "func", "lex", "(", "input", "string", ")", "[", "]", "*", "token", "{", "var", "tokens", "[", "]", "*", "token", "\n", "l", ":=", "&", "lexer", "{", "0", ",", "0", ",", "0", ",", "len", "(", "input", ")", ",", "input", "}", "\n", "for", "{...
// lex reads SPF record and returns list of Tokens along with // their modifiers and values. Parser should parse the Tokens and execute // relevant actions
[ "lex", "reads", "SPF", "record", "and", "returns", "list", "of", "Tokens", "along", "with", "their", "modifiers", "and", "values", ".", "Parser", "should", "parse", "the", "Tokens", "and", "execute", "relevant", "actions" ]
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/lexer.go#L20-L31
153,595
zaccone/spf
lexer.go
scan
func (l *lexer) scan() *token { for { r, eof := l.next() if eof { return &token{tEOF, tEOF, ""} } else if isWhitespace(r) || l.eof() { // we just scanned some meaningful data token := l.scanIdent() l.scanWhitespaces() l.moveon() return token } } }
go
func (l *lexer) scan() *token { for { r, eof := l.next() if eof { return &token{tEOF, tEOF, ""} } else if isWhitespace(r) || l.eof() { // we just scanned some meaningful data token := l.scanIdent() l.scanWhitespaces() l.moveon() return token } } }
[ "func", "(", "l", "*", "lexer", ")", "scan", "(", ")", "*", "token", "{", "for", "{", "r", ",", "eof", ":=", "l", ".", "next", "(", ")", "\n", "if", "eof", "{", "return", "&", "token", "{", "tEOF", ",", "tEOF", ",", "\"", "\"", "}", "\n", ...
// scan scans input and returns a Token structure
[ "scan", "scans", "input", "and", "returns", "a", "Token", "structure" ]
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/lexer.go#L34-L46
153,596
zaccone/spf
lexer.go
scanWhitespaces
func (l *lexer) scanWhitespaces() { for { if ch, eof := l.next(); eof { return } else if !isWhitespace(ch) { l.back() return } } }
go
func (l *lexer) scanWhitespaces() { for { if ch, eof := l.next(); eof { return } else if !isWhitespace(ch) { l.back() return } } }
[ "func", "(", "l", "*", "lexer", ")", "scanWhitespaces", "(", ")", "{", "for", "{", "if", "ch", ",", "eof", ":=", "l", ".", "next", "(", ")", ";", "eof", "{", "return", "\n", "}", "else", "if", "!", "isWhitespace", "(", "ch", ")", "{", "l", "....
// scanWhitespaces moves position to a first rune which is not a // whitespace or tab
[ "scanWhitespaces", "moves", "position", "to", "a", "first", "rune", "which", "is", "not", "a", "whitespace", "or", "tab" ]
76747b8658d9b8686ce812a0e3a2d3be904c980e
https://github.com/zaccone/spf/blob/76747b8658d9b8686ce812a0e3a2d3be904c980e/lexer.go#L74-L83
153,597
edeckers/auroradnsclient
tokens/generator.go
NewToken
func NewToken(userID string, key string, method string, action string, timestamp time.Time) string { fmtTime := timestamp.Format("20060102T150405Z") logrus.Debugf("Built timestamp: %s", fmtTime) message := strings.Join([]string{method, action, fmtTime}, "") logrus.Debugf("Built message: %s", message) signatureHmac := hmac.New(sha256.New, []byte(key)) signatureHmac.Write([]byte(message)) signature := base64.StdEncoding.EncodeToString([]byte(signatureHmac.Sum(nil))) logrus.Debugf("Built signature: %s", signature) userIDAndSignature := fmt.Sprintf("%s:%s", userID, signature) token := base64.StdEncoding.EncodeToString([]byte(userIDAndSignature)) logrus.Debugf("Built token: %s", token) return token }
go
func NewToken(userID string, key string, method string, action string, timestamp time.Time) string { fmtTime := timestamp.Format("20060102T150405Z") logrus.Debugf("Built timestamp: %s", fmtTime) message := strings.Join([]string{method, action, fmtTime}, "") logrus.Debugf("Built message: %s", message) signatureHmac := hmac.New(sha256.New, []byte(key)) signatureHmac.Write([]byte(message)) signature := base64.StdEncoding.EncodeToString([]byte(signatureHmac.Sum(nil))) logrus.Debugf("Built signature: %s", signature) userIDAndSignature := fmt.Sprintf("%s:%s", userID, signature) token := base64.StdEncoding.EncodeToString([]byte(userIDAndSignature)) logrus.Debugf("Built token: %s", token) return token }
[ "func", "NewToken", "(", "userID", "string", ",", "key", "string", ",", "method", "string", ",", "action", "string", ",", "timestamp", "time", ".", "Time", ")", "string", "{", "fmtTime", ":=", "timestamp", ".", "Format", "(", "\"", "\"", ")", "\n", "lo...
// NewToken generates a token for accessing a specific method of the API
[ "NewToken", "generates", "a", "token", "for", "accessing", "a", "specific", "method", "of", "the", "API" ]
1563e622aaca0a8bb895a448f31d4a430ab97586
https://github.com/edeckers/auroradnsclient/blob/1563e622aaca0a8bb895a448f31d4a430ab97586/tokens/generator.go#L15-L35
153,598
edeckers/auroradnsclient
client.go
NewAuroraDNSClient
func NewAuroraDNSClient(endpoint string, userID string, key string) (*AuroraDNSClient, error) { requestor, err := requests.NewAuroraRequestor(endpoint, userID, key) if err != nil { return nil, err } return &AuroraDNSClient{ requestor: requestor, }, nil }
go
func NewAuroraDNSClient(endpoint string, userID string, key string) (*AuroraDNSClient, error) { requestor, err := requests.NewAuroraRequestor(endpoint, userID, key) if err != nil { return nil, err } return &AuroraDNSClient{ requestor: requestor, }, nil }
[ "func", "NewAuroraDNSClient", "(", "endpoint", "string", ",", "userID", "string", ",", "key", "string", ")", "(", "*", "AuroraDNSClient", ",", "error", ")", "{", "requestor", ",", "err", ":=", "requests", ".", "NewAuroraRequestor", "(", "endpoint", ",", "use...
// NewAuroraDNSClient instantiates a new client
[ "NewAuroraDNSClient", "instantiates", "a", "new", "client" ]
1563e622aaca0a8bb895a448f31d4a430ab97586
https://github.com/edeckers/auroradnsclient/blob/1563e622aaca0a8bb895a448f31d4a430ab97586/client.go#L13-L22
153,599
catalyzeio/gcm
gcm/gcm.go
DecryptFile
func DecryptFile(inFilePath, outFilePath string, key, iv, aad []byte) error { if _, err := os.Stat(inFilePath); os.IsNotExist(err) { return fmt.Errorf("A file does not exist at %s", inFilePath) } inFile, err := os.Open(inFilePath) if err != nil { return err } defer inFile.Close() outFile, err := os.OpenFile(outFilePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600) if err != nil { return err } defer outFile.Close() w, err := NewDecryptWriteCloser(outFile, key, iv, aad) if err != nil { return err } defer w.Close() _, err = io.Copy(w, inFile) return err }
go
func DecryptFile(inFilePath, outFilePath string, key, iv, aad []byte) error { if _, err := os.Stat(inFilePath); os.IsNotExist(err) { return fmt.Errorf("A file does not exist at %s", inFilePath) } inFile, err := os.Open(inFilePath) if err != nil { return err } defer inFile.Close() outFile, err := os.OpenFile(outFilePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600) if err != nil { return err } defer outFile.Close() w, err := NewDecryptWriteCloser(outFile, key, iv, aad) if err != nil { return err } defer w.Close() _, err = io.Copy(w, inFile) return err }
[ "func", "DecryptFile", "(", "inFilePath", ",", "outFilePath", "string", ",", "key", ",", "iv", ",", "aad", "[", "]", "byte", ")", "error", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "inFilePath", ")", ";", "os", ".", "IsNotExist", "(...
// DecryptFile decrypts the file at the specified path using GCM.
[ "DecryptFile", "decrypts", "the", "file", "at", "the", "specified", "path", "using", "GCM", "." ]
380bb1925bb96de540e745dfeba12fd6c3fd21f8
https://github.com/catalyzeio/gcm/blob/380bb1925bb96de540e745dfeba12fd6c3fd21f8/gcm/gcm.go#L46-L71