id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
30,600
ahmdrz/goinsta
goinsta.go
ImportReader
func ImportReader(r io.Reader) (*Instagram, error) { url, err := neturl.Parse(goInstaAPIUrl) if err != nil { return nil, err } bytes, err := ioutil.ReadAll(r) if err != nil { return nil, err } config := ConfigFile{} err = json.Unmarshal(bytes, &config) if err != nil { return nil, err } inst := &Insta...
go
func ImportReader(r io.Reader) (*Instagram, error) { url, err := neturl.Parse(goInstaAPIUrl) if err != nil { return nil, err } bytes, err := ioutil.ReadAll(r) if err != nil { return nil, err } config := ConfigFile{} err = json.Unmarshal(bytes, &config) if err != nil { return nil, err } inst := &Insta...
[ "func", "ImportReader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Instagram", ",", "error", ")", "{", "url", ",", "err", ":=", "neturl", ".", "Parse", "(", "goInstaAPIUrl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err",...
// ImportReader imports instagram configuration from io.Reader // // This function does not set proxy automatically. Use SetProxy after this call.
[ "ImportReader", "imports", "instagram", "configuration", "from", "io", ".", "Reader", "This", "function", "does", "not", "set", "proxy", "automatically", ".", "Use", "SetProxy", "after", "this", "call", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/goinsta.go#L211-L251
30,601
ahmdrz/goinsta
goinsta.go
Import
func Import(path string) (*Instagram, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() return ImportReader(f) }
go
func Import(path string) (*Instagram, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() return ImportReader(f) }
[ "func", "Import", "(", "path", "string", ")", "(", "*", "Instagram", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer",...
// Import imports instagram configuration // // This function does not set proxy automatically. Use SetProxy after this call.
[ "Import", "imports", "instagram", "configuration", "This", "function", "does", "not", "set", "proxy", "automatically", ".", "Use", "SetProxy", "after", "this", "call", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/goinsta.go#L256-L263
30,602
ahmdrz/goinsta
goinsta.go
Login
func (inst *Instagram) Login() error { err := inst.readMsisdnHeader() if err != nil { return err } err = inst.syncFeatures() if err != nil { return err } err = inst.zrToken() if err != nil { return err } err = inst.sendAdID() if err != nil { return err } err = inst.contactPrefill() if err != n...
go
func (inst *Instagram) Login() error { err := inst.readMsisdnHeader() if err != nil { return err } err = inst.syncFeatures() if err != nil { return err } err = inst.zrToken() if err != nil { return err } err = inst.sendAdID() if err != nil { return err } err = inst.contactPrefill() if err != n...
[ "func", "(", "inst", "*", "Instagram", ")", "Login", "(", ")", "error", "{", "err", ":=", "inst", ".", "readMsisdnHeader", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "inst", ".", "syncFeatures", "...
// Login performs instagram login. // // Password will be deleted after login
[ "Login", "performs", "instagram", "login", ".", "Password", "will", "be", "deleted", "after", "login" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/goinsta.go#L347-L415
30,603
ahmdrz/goinsta
goinsta.go
Logout
func (inst *Instagram) Logout() error { _, err := inst.sendSimpleRequest(urlLogout) inst.c.Jar = nil inst.c = nil return err }
go
func (inst *Instagram) Logout() error { _, err := inst.sendSimpleRequest(urlLogout) inst.c.Jar = nil inst.c = nil return err }
[ "func", "(", "inst", "*", "Instagram", ")", "Logout", "(", ")", "error", "{", "_", ",", "err", ":=", "inst", ".", "sendSimpleRequest", "(", "urlLogout", ")", "\n", "inst", ".", "c", ".", "Jar", "=", "nil", "\n", "inst", ".", "c", "=", "nil", "\n"...
// Logout closes current session
[ "Logout", "closes", "current", "session" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/goinsta.go#L418-L423
30,604
ahmdrz/goinsta
search.go
User
func (search *Search) User(user string) (*SearchResult, error) { insta := search.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSearchUser, Query: map[string]string{ "ig_sig_key_version": goInstaSigKeyVersion, "is_typeahead": "true", "query": user, "rank_toke...
go
func (search *Search) User(user string) (*SearchResult, error) { insta := search.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSearchUser, Query: map[string]string{ "ig_sig_key_version": goInstaSigKeyVersion, "is_typeahead": "true", "query": user, "rank_toke...
[ "func", "(", "search", "*", "Search", ")", "User", "(", "user", "string", ")", "(", "*", "SearchResult", ",", "error", ")", "{", "insta", ":=", "search", ".", "inst", "\n", "body", ",", "err", ":=", "insta", ".", "sendRequest", "(", "&", "reqOptions"...
// User search by username
[ "User", "search", "by", "username" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/search.go#L73-L93
30,605
ahmdrz/goinsta
search.go
Tags
func (search *Search) Tags(tag string) (*SearchResult, error) { insta := search.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSearchTag, Query: map[string]string{ "is_typeahead": "true", "rank_token": insta.rankToken, "q": tag, }, }, ) if err != nil { return ...
go
func (search *Search) Tags(tag string) (*SearchResult, error) { insta := search.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSearchTag, Query: map[string]string{ "is_typeahead": "true", "rank_token": insta.rankToken, "q": tag, }, }, ) if err != nil { return ...
[ "func", "(", "search", "*", "Search", ")", "Tags", "(", "tag", "string", ")", "(", "*", "SearchResult", ",", "error", ")", "{", "insta", ":=", "search", ".", "inst", "\n", "body", ",", "err", ":=", "insta", ".", "sendRequest", "(", "&", "reqOptions",...
// Tags search by tag
[ "Tags", "search", "by", "tag" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/search.go#L96-L115
30,606
ahmdrz/goinsta
search.go
Facebook
func (search *Search) Facebook(user string) (*SearchResult, error) { insta := search.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSearchFacebook, Query: map[string]string{ "query": user, "rank_token": insta.rankToken, }, }, ) if err != nil { return nil, err } res := &...
go
func (search *Search) Facebook(user string) (*SearchResult, error) { insta := search.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSearchFacebook, Query: map[string]string{ "query": user, "rank_token": insta.rankToken, }, }, ) if err != nil { return nil, err } res := &...
[ "func", "(", "search", "*", "Search", ")", "Facebook", "(", "user", "string", ")", "(", "*", "SearchResult", ",", "error", ")", "{", "insta", ":=", "search", ".", "inst", "\n", "body", ",", "err", ":=", "insta", ".", "sendRequest", "(", "&", "reqOpti...
// Facebook search by facebook user.
[ "Facebook", "search", "by", "facebook", "user", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/search.go#L151-L168
30,607
ahmdrz/goinsta
types.go
GetBest
func (img Images) GetBest() string { best := "" var mh, mw int for _, v := range img.Versions { if v.Width > mw || v.Height > mh { best = v.URL mh, mw = v.Height, v.Width } } return best }
go
func (img Images) GetBest() string { best := "" var mh, mw int for _, v := range img.Versions { if v.Width > mw || v.Height > mh { best = v.URL mh, mw = v.Height, v.Width } } return best }
[ "func", "(", "img", "Images", ")", "GetBest", "(", ")", "string", "{", "best", ":=", "\"", "\"", "\n", "var", "mh", ",", "mw", "int", "\n", "for", "_", ",", "v", ":=", "range", "img", ".", "Versions", "{", "if", "v", ".", "Width", ">", "mw", ...
// GetBest returns the URL of the image with the best quality.
[ "GetBest", "returns", "the", "URL", "of", "the", "image", "with", "the", "best", "quality", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/types.go#L149-L159
30,608
ahmdrz/goinsta
types.go
Unblock
func (b *BlockedUser) Unblock() error { u := User{ID: b.UserID} return u.Unblock() }
go
func (b *BlockedUser) Unblock() error { u := User{ID: b.UserID} return u.Unblock() }
[ "func", "(", "b", "*", "BlockedUser", ")", "Unblock", "(", ")", "error", "{", "u", ":=", "User", "{", "ID", ":", "b", ".", "UserID", "}", "\n", "return", "u", ".", "Unblock", "(", ")", "\n", "}" ]
// Unblock unblocks blocked user.
[ "Unblock", "unblocks", "blocked", "user", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/types.go#L297-L300
30,609
ahmdrz/goinsta
utils.go
getImageDimensionFromReader
func getImageDimensionFromReader(rdr io.Reader) (int, int, error) { image, _, err := image.DecodeConfig(rdr) if err != nil { return 0, 0, err } return image.Width, image.Height, nil }
go
func getImageDimensionFromReader(rdr io.Reader) (int, int, error) { image, _, err := image.DecodeConfig(rdr) if err != nil { return 0, 0, err } return image.Width, image.Height, nil }
[ "func", "getImageDimensionFromReader", "(", "rdr", "io", ".", "Reader", ")", "(", "int", ",", "int", ",", "error", ")", "{", "image", ",", "_", ",", "err", ":=", "image", ".", "DecodeConfig", "(", "rdr", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// getImageDimensionFromReader return image dimension , types is .jpg and .png
[ "getImageDimensionFromReader", "return", "image", "dimension", "types", "is", ".", "jpg", "and", ".", "png" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/utils.go#L75-L81
30,610
ahmdrz/goinsta
account.go
Sync
func (account *Account) Sync() error { insta := account.inst data, err := insta.prepareData() if err != nil { return err } body, err := insta.sendRequest(&reqOptions{ Endpoint: urlCurrentUser, Query: generateSignature(data), IsPost: true, }) if err == nil { resp := profResp{} err = json.Unmarsha...
go
func (account *Account) Sync() error { insta := account.inst data, err := insta.prepareData() if err != nil { return err } body, err := insta.sendRequest(&reqOptions{ Endpoint: urlCurrentUser, Query: generateSignature(data), IsPost: true, }) if err == nil { resp := profResp{} err = json.Unmarsha...
[ "func", "(", "account", "*", "Account", ")", "Sync", "(", ")", "error", "{", "insta", ":=", "account", ".", "inst", "\n", "data", ",", "err", ":=", "insta", ".", "prepareData", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", ...
// Sync updates account information
[ "Sync", "updates", "account", "information" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/account.go#L74-L94
30,611
ahmdrz/goinsta
account.go
Saved
func (account *Account) Saved() (*SavedMedia, error) { body, err := account.inst.sendSimpleRequest(urlUserTags, account.ID) if err == nil { media := &SavedMedia{} err = json.Unmarshal(body, &media) return media, err } return nil, err }
go
func (account *Account) Saved() (*SavedMedia, error) { body, err := account.inst.sendSimpleRequest(urlUserTags, account.ID) if err == nil { media := &SavedMedia{} err = json.Unmarshal(body, &media) return media, err } return nil, err }
[ "func", "(", "account", "*", "Account", ")", "Saved", "(", ")", "(", "*", "SavedMedia", ",", "error", ")", "{", "body", ",", "err", ":=", "account", ".", "inst", ".", "sendSimpleRequest", "(", "urlUserTags", ",", "account", ".", "ID", ")", "\n", "if"...
// Saved returns saved media.
[ "Saved", "returns", "saved", "media", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/account.go#L312-L320
30,612
ahmdrz/goinsta
account.go
SetBiography
func (account *Account) SetBiography(bio string) error { account.edit() // preparing to edit insta := account.inst data, err := insta.prepareData( map[string]interface{}{ "raw_text": bio, }, ) if err != nil { return err } body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSetBiography, Q...
go
func (account *Account) SetBiography(bio string) error { account.edit() // preparing to edit insta := account.inst data, err := insta.prepareData( map[string]interface{}{ "raw_text": bio, }, ) if err != nil { return err } body, err := insta.sendRequest( &reqOptions{ Endpoint: urlSetBiography, Q...
[ "func", "(", "account", "*", "Account", ")", "SetBiography", "(", "bio", "string", ")", "error", "{", "account", ".", "edit", "(", ")", "// preparing to edit", "\n", "insta", ":=", "account", ".", "inst", "\n", "data", ",", "err", ":=", "insta", ".", "...
// SetBiography changes your Instagram's biography. // // This function updates current Account information.
[ "SetBiography", "changes", "your", "Instagram", "s", "biography", ".", "This", "function", "updates", "current", "Account", "information", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/account.go#L350-L383
30,613
ahmdrz/goinsta
account.go
Liked
func (account *Account) Liked() *FeedMedia { insta := account.inst media := &FeedMedia{} media.inst = insta media.endpoint = urlFeedLiked return media }
go
func (account *Account) Liked() *FeedMedia { insta := account.inst media := &FeedMedia{} media.inst = insta media.endpoint = urlFeedLiked return media }
[ "func", "(", "account", "*", "Account", ")", "Liked", "(", ")", "*", "FeedMedia", "{", "insta", ":=", "account", ".", "inst", "\n\n", "media", ":=", "&", "FeedMedia", "{", "}", "\n", "media", ".", "inst", "=", "insta", "\n", "media", ".", "endpoint",...
// Liked are liked publications
[ "Liked", "are", "liked", "publications" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/account.go#L386-L393
30,614
ahmdrz/goinsta
account.go
PendingFollowRequests
func (account *Account) PendingFollowRequests() ([]User, error) { insta := account.inst resp, err := insta.sendRequest( &reqOptions{ Endpoint: urlFriendshipPending, }, ) if err != nil { return nil, err } var result struct { Users []User `json:"users"` // TODO: pagination // TODO: SuggestedUsers ...
go
func (account *Account) PendingFollowRequests() ([]User, error) { insta := account.inst resp, err := insta.sendRequest( &reqOptions{ Endpoint: urlFriendshipPending, }, ) if err != nil { return nil, err } var result struct { Users []User `json:"users"` // TODO: pagination // TODO: SuggestedUsers ...
[ "func", "(", "account", "*", "Account", ")", "PendingFollowRequests", "(", ")", "(", "[", "]", "User", ",", "error", ")", "{", "insta", ":=", "account", ".", "inst", "\n", "resp", ",", "err", ":=", "insta", ".", "sendRequest", "(", "&", "reqOptions", ...
// PendingFollowRequests returns pending follow requests.
[ "PendingFollowRequests", "returns", "pending", "follow", "requests", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/account.go#L396-L422
30,615
ahmdrz/goinsta
feeds.go
LocationID
func (feed *Feed) LocationID(locationID int64) (*FeedLocation, error) { insta := feed.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlFeedLocationID, locationID), Query: map[string]string{ "rank_token": insta.rankToken, "ranked_content": "true", }, }, ) if err != ...
go
func (feed *Feed) LocationID(locationID int64) (*FeedLocation, error) { insta := feed.inst body, err := insta.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlFeedLocationID, locationID), Query: map[string]string{ "rank_token": insta.rankToken, "ranked_content": "true", }, }, ) if err != ...
[ "func", "(", "feed", "*", "Feed", ")", "LocationID", "(", "locationID", "int64", ")", "(", "*", "FeedLocation", ",", "error", ")", "{", "insta", ":=", "feed", ".", "inst", "\n", "body", ",", "err", ":=", "insta", ".", "sendRequest", "(", "&", "reqOpt...
// Feed search by locationID
[ "Feed", "search", "by", "locationID" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/feeds.go#L21-L39
30,616
ahmdrz/goinsta
media.go
SyncLikers
func (item *Item) SyncLikers() error { resp := respLikers{} insta := item.media.instagram() body, err := insta.sendSimpleRequest(urlMediaLikers, item.ID) if err != nil { return err } err = json.Unmarshal(body, &resp) if err == nil { item.Likers = resp.Users } return err }
go
func (item *Item) SyncLikers() error { resp := respLikers{} insta := item.media.instagram() body, err := insta.sendSimpleRequest(urlMediaLikers, item.ID) if err != nil { return err } err = json.Unmarshal(body, &resp) if err == nil { item.Likers = resp.Users } return err }
[ "func", "(", "item", "*", "Item", ")", "SyncLikers", "(", ")", "error", "{", "resp", ":=", "respLikers", "{", "}", "\n", "insta", ":=", "item", ".", "media", ".", "instagram", "(", ")", "\n", "body", ",", "err", ":=", "insta", ".", "sendSimpleRequest...
// SyncLikers fetch new likers of a media // // This function updates Item.Likers value
[ "SyncLikers", "fetch", "new", "likers", "of", "a", "media", "This", "function", "updates", "Item", ".", "Likers", "value" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/media.go#L249-L261
30,617
ahmdrz/goinsta
media.go
ID
func (media *StoryMedia) ID() string { switch id := media.Pk.(type) { case int64: return strconv.FormatInt(id, 10) case string: return id } return "" }
go
func (media *StoryMedia) ID() string { switch id := media.Pk.(type) { case int64: return strconv.FormatInt(id, 10) case string: return id } return "" }
[ "func", "(", "media", "*", "StoryMedia", ")", "ID", "(", ")", "string", "{", "switch", "id", ":=", "media", ".", "Pk", ".", "(", "type", ")", "{", "case", "int64", ":", "return", "strconv", ".", "FormatInt", "(", "id", ",", "10", ")", "\n", "case...
// ID returns Story id
[ "ID", "returns", "Story", "id" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/media.go#L524-L532
30,618
ahmdrz/goinsta
media.go
Sync
func (media *StoryMedia) Sync() error { insta := media.inst query := []trayRequest{ {"SUPPORTED_SDK_VERSIONS", "9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0"}, {"FACE_TRACKER_VERSION", "10"}, {"segmentation", "segmentation_enabled"}, {"COMPRESSION", "ETC2_COMPRESSION"}, } q...
go
func (media *StoryMedia) Sync() error { insta := media.inst query := []trayRequest{ {"SUPPORTED_SDK_VERSIONS", "9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0"}, {"FACE_TRACKER_VERSION", "10"}, {"segmentation", "segmentation_enabled"}, {"COMPRESSION", "ETC2_COMPRESSION"}, } q...
[ "func", "(", "media", "*", "StoryMedia", ")", "Sync", "(", ")", "error", "{", "insta", ":=", "media", ".", "inst", "\n", "query", ":=", "[", "]", "trayRequest", "{", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "{", "\"", "\"", ",", "\"", "\"", ...
// Sync function is used when Highlight must be sync. // Highlight must be sync when User.Highlights does not return any object inside StoryMedia slice. // // This function does NOT update Stories items. // // This function updates StoryMedia.Items
[ "Sync", "function", "is", "used", "when", "Highlight", "must", "be", "sync", ".", "Highlight", "must", "be", "sync", "when", "User", ".", "Highlights", "does", "not", "return", "any", "object", "inside", "StoryMedia", "slice", ".", "This", "function", "does"...
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/media.go#L589-L634
30,619
ahmdrz/goinsta
media.go
Sync
func (media *FeedMedia) Sync() error { id := media.ID() insta := media.inst data, err := insta.prepareData( map[string]interface{}{ "media_id": id, }, ) if err != nil { return err } body, err := insta.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlMediaInfo, id), Query: generateSignatur...
go
func (media *FeedMedia) Sync() error { id := media.ID() insta := media.inst data, err := insta.prepareData( map[string]interface{}{ "media_id": id, }, ) if err != nil { return err } body, err := insta.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlMediaInfo, id), Query: generateSignatur...
[ "func", "(", "media", "*", "FeedMedia", ")", "Sync", "(", ")", "error", "{", "id", ":=", "media", ".", "ID", "(", ")", "\n", "insta", ":=", "media", ".", "inst", "\n\n", "data", ",", "err", ":=", "insta", ".", "prepareData", "(", "map", "[", "str...
// Sync updates media values.
[ "Sync", "updates", "media", "values", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/media.go#L717-L749
30,620
ahmdrz/goinsta
media.go
ID
func (media *FeedMedia) ID() string { switch s := media.NextID.(type) { case string: return s case int64: return strconv.FormatInt(s, 10) case json.Number: return string(s) } return "" }
go
func (media *FeedMedia) ID() string { switch s := media.NextID.(type) { case string: return s case int64: return strconv.FormatInt(s, 10) case json.Number: return string(s) } return "" }
[ "func", "(", "media", "*", "FeedMedia", ")", "ID", "(", ")", "string", "{", "switch", "s", ":=", "media", ".", "NextID", ".", "(", "type", ")", "{", "case", "string", ":", "return", "s", "\n", "case", "int64", ":", "return", "strconv", ".", "Format...
// ID returns media id.
[ "ID", "returns", "media", "id", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/media.go#L762-L772
30,621
ahmdrz/goinsta
inbox.go
Write
func (c *Conversation) Write(b []byte) (int, error) { n := len(b) return n, c.Send(b2s(b)) }
go
func (c *Conversation) Write(b []byte) (int, error) { n := len(b) return n, c.Send(b2s(b)) }
[ "func", "(", "c", "*", "Conversation", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "n", ":=", "len", "(", "b", ")", "\n", "return", "n", ",", "c", ".", "Send", "(", "b2s", "(", "b", ")", ")", "\n", "...
// Write is like Send but being compatible with io.Writer.
[ "Write", "is", "like", "Send", "but", "being", "compatible", "with", "io", ".", "Writer", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/inbox.go#L340-L343
30,622
ahmdrz/goinsta
comments.go
Next
func (comments *Comments) Next() bool { if comments.err != nil { return false } item := comments.item insta := item.media.instagram() endpoint := comments.endpoint query := map[string]string{ // "can_support_threading": "true", } if comments.NextMaxID != nil { next, _ := strconv.Unquote(string(comments.N...
go
func (comments *Comments) Next() bool { if comments.err != nil { return false } item := comments.item insta := item.media.instagram() endpoint := comments.endpoint query := map[string]string{ // "can_support_threading": "true", } if comments.NextMaxID != nil { next, _ := strconv.Unquote(string(comments.N...
[ "func", "(", "comments", "*", "Comments", ")", "Next", "(", ")", "bool", "{", "if", "comments", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "item", ":=", "comments", ".", "item", "\n", "insta", ":=", "item", ".", "media", "....
// Next allows comment pagination. // // This function support concurrency methods to get comments using Last and Next ID // // New comments are stored in Comments.Items
[ "Next", "allows", "comment", "pagination", ".", "This", "function", "support", "concurrency", "methods", "to", "get", "comments", "using", "Last", "and", "Next", "ID", "New", "comments", "are", "stored", "in", "Comments", ".", "Items" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/comments.go#L117-L160
30,623
ahmdrz/goinsta
comments.go
Del
func (comments *Comments) Del(comment *Comment) error { insta := comments.item.media.instagram() data, err := insta.prepareData() if err != nil { return err } id := comment.getid() _, err = insta.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlCommentDelete, comments.item.ID, id), Query: generat...
go
func (comments *Comments) Del(comment *Comment) error { insta := comments.item.media.instagram() data, err := insta.prepareData() if err != nil { return err } id := comment.getid() _, err = insta.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlCommentDelete, comments.item.ID, id), Query: generat...
[ "func", "(", "comments", "*", "Comments", ")", "Del", "(", "comment", "*", "Comment", ")", "error", "{", "insta", ":=", "comments", ".", "item", ".", "media", ".", "instagram", "(", ")", "\n\n", "data", ",", "err", ":=", "insta", ".", "prepareData", ...
// Del deletes comment.
[ "Del", "deletes", "comment", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/comments.go#L230-L247
30,624
ahmdrz/goinsta
comments.go
Like
func (c *Comment) Like() error { data, err := c.inst.prepareData() if err != nil { return err } _, err = c.inst.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlCommentLike, c.getid()), Query: generateSignature(data), IsPost: true, }, ) return err }
go
func (c *Comment) Like() error { data, err := c.inst.prepareData() if err != nil { return err } _, err = c.inst.sendRequest( &reqOptions{ Endpoint: fmt.Sprintf(urlCommentLike, c.getid()), Query: generateSignature(data), IsPost: true, }, ) return err }
[ "func", "(", "c", "*", "Comment", ")", "Like", "(", ")", "error", "{", "data", ",", "err", ":=", "c", ".", "inst", ".", "prepareData", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "_", ",", "err", "=", "c...
// Like likes comment.
[ "Like", "likes", "comment", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/comments.go#L339-L353
30,625
ahmdrz/goinsta
hashtags.go
NewHashtag
func (inst *Instagram) NewHashtag(name string) *Hashtag { return &Hashtag{ inst: inst, Name: name, } }
go
func (inst *Instagram) NewHashtag(name string) *Hashtag { return &Hashtag{ inst: inst, Name: name, } }
[ "func", "(", "inst", "*", "Instagram", ")", "NewHashtag", "(", "name", "string", ")", "*", "Hashtag", "{", "return", "&", "Hashtag", "{", "inst", ":", "inst", ",", "Name", ":", "name", ",", "}", "\n", "}" ]
// NewHashtag returns initialised hashtag structure // Name parameter is hashtag name
[ "NewHashtag", "returns", "initialised", "hashtag", "structure", "Name", "parameter", "is", "hashtag", "name" ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/hashtags.go#L56-L61
30,626
ahmdrz/goinsta
hashtags.go
Sync
func (h *Hashtag) Sync() error { insta := h.inst body, err := insta.sendSimpleRequest(urlTagSync, h.Name) if err == nil { var resp struct { Name string `json:"name"` ID int64 `json:"id"` MediaCount int `json:"media_count"` } err = json.Unmarshal(body, &resp) if err == nil { h.N...
go
func (h *Hashtag) Sync() error { insta := h.inst body, err := insta.sendSimpleRequest(urlTagSync, h.Name) if err == nil { var resp struct { Name string `json:"name"` ID int64 `json:"id"` MediaCount int `json:"media_count"` } err = json.Unmarshal(body, &resp) if err == nil { h.N...
[ "func", "(", "h", "*", "Hashtag", ")", "Sync", "(", ")", "error", "{", "insta", ":=", "h", ".", "inst", "\n\n", "body", ",", "err", ":=", "insta", ".", "sendSimpleRequest", "(", "urlTagSync", ",", "h", ".", "Name", ")", "\n", "if", "err", "==", "...
// Sync updates Hashtag information preparing it to Next call.
[ "Sync", "updates", "Hashtag", "information", "preparing", "it", "to", "Next", "call", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/hashtags.go#L64-L83
30,627
ahmdrz/goinsta
hashtags.go
Stories
func (h *Hashtag) Stories() (*StoryMedia, error) { body, err := h.inst.sendSimpleRequest( urlTagStories, h.Name, ) if err == nil { var resp struct { Story StoryMedia `json:"story"` Status string `json:"status"` } err = json.Unmarshal(body, &resp) return &resp.Story, err } return nil, err }
go
func (h *Hashtag) Stories() (*StoryMedia, error) { body, err := h.inst.sendSimpleRequest( urlTagStories, h.Name, ) if err == nil { var resp struct { Story StoryMedia `json:"story"` Status string `json:"status"` } err = json.Unmarshal(body, &resp) return &resp.Story, err } return nil, err }
[ "func", "(", "h", "*", "Hashtag", ")", "Stories", "(", ")", "(", "*", "StoryMedia", ",", "error", ")", "{", "body", ",", "err", ":=", "h", ".", "inst", ".", "sendSimpleRequest", "(", "urlTagStories", ",", "h", ".", "Name", ",", ")", "\n", "if", "...
// Stories returns hashtag stories.
[ "Stories", "returns", "hashtag", "stories", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/hashtags.go#L127-L140
30,628
ahmdrz/goinsta
profiles.go
Blocked
func (prof *Profiles) Blocked() ([]BlockedUser, error) { body, err := prof.inst.sendSimpleRequest(urlBlockedList) if err == nil { resp := blockedListResp{} err = json.Unmarshal(body, &resp) return resp.BlockedList, err } return nil, err }
go
func (prof *Profiles) Blocked() ([]BlockedUser, error) { body, err := prof.inst.sendSimpleRequest(urlBlockedList) if err == nil { resp := blockedListResp{} err = json.Unmarshal(body, &resp) return resp.BlockedList, err } return nil, err }
[ "func", "(", "prof", "*", "Profiles", ")", "Blocked", "(", ")", "(", "[", "]", "BlockedUser", ",", "error", ")", "{", "body", ",", "err", ":=", "prof", ".", "inst", ".", "sendSimpleRequest", "(", "urlBlockedList", ")", "\n", "if", "err", "==", "nil",...
// Blocked returns a list of blocked profiles.
[ "Blocked", "returns", "a", "list", "of", "blocked", "profiles", "." ]
86d8297fa4152941d864ca6d7d2e1f1f673708aa
https://github.com/ahmdrz/goinsta/blob/86d8297fa4152941d864ca6d7d2e1f1f673708aa/profiles.go#L61-L69
30,629
mailru/easyjson
opt/gotemplate_Uint64.go
MarshalJSON
func (v Uint64) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} v.MarshalEasyJSON(&w) return w.Buffer.BuildBytes(), w.Error }
go
func (v Uint64) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} v.MarshalEasyJSON(&w) return w.Buffer.BuildBytes(), w.Error }
[ "func", "(", "v", "Uint64", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "v", ".", "MarshalEasyJSON", "(", "&", "w", ")", "\n", "return", "w", ".", "Buffer", "...
// MarshalJSON implements a standard json marshaler interface.
[ "MarshalJSON", "implements", "a", "standard", "json", "marshaler", "interface", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/opt/gotemplate_Uint64.go#L54-L58
30,630
mailru/easyjson
opt/gotemplate_Uint64.go
UnmarshalJSON
func (v *Uint64) UnmarshalJSON(data []byte) error { l := jlexer.Lexer{Data: data} v.UnmarshalEasyJSON(&l) return l.Error() }
go
func (v *Uint64) UnmarshalJSON(data []byte) error { l := jlexer.Lexer{Data: data} v.UnmarshalEasyJSON(&l) return l.Error() }
[ "func", "(", "v", "*", "Uint64", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "l", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "v", ".", "UnmarshalEasyJSON", "(", "&", "l", ")", "\n", "return", "l...
// UnmarshalJSON implements a standard json unmarshaler interface.
[ "UnmarshalJSON", "implements", "a", "standard", "json", "unmarshaler", "interface", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/opt/gotemplate_Uint64.go#L61-L65
30,631
mailru/easyjson
gen/decoder.go
genTypeDecoder
func (g *Generator) genTypeDecoder(t reflect.Type, out string, tags fieldTags, indent int) error { ws := strings.Repeat(" ", indent) unmarshalerIface := reflect.TypeOf((*easyjson.Unmarshaler)(nil)).Elem() if reflect.PtrTo(t).Implements(unmarshalerIface) { fmt.Fprintln(g.out, ws+"("+out+").UnmarshalEasyJSON(in)")...
go
func (g *Generator) genTypeDecoder(t reflect.Type, out string, tags fieldTags, indent int) error { ws := strings.Repeat(" ", indent) unmarshalerIface := reflect.TypeOf((*easyjson.Unmarshaler)(nil)).Elem() if reflect.PtrTo(t).Implements(unmarshalerIface) { fmt.Fprintln(g.out, ws+"("+out+").UnmarshalEasyJSON(in)")...
[ "func", "(", "g", "*", "Generator", ")", "genTypeDecoder", "(", "t", "reflect", ".", "Type", ",", "out", "string", ",", "tags", "fieldTags", ",", "indent", "int", ")", "error", "{", "ws", ":=", "strings", ".", "Repeat", "(", "\"", "\"", ",", "indent"...
// genTypeDecoder generates decoding code for the type t, but uses unmarshaler interface if implemented by t.
[ "genTypeDecoder", "generates", "decoding", "code", "for", "the", "type", "t", "but", "uses", "unmarshaler", "interface", "if", "implemented", "by", "t", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/decoder.go#L60-L87
30,632
mailru/easyjson
gen/decoder.go
hasCustomUnmarshaler
func hasCustomUnmarshaler(t reflect.Type) bool { t = reflect.PtrTo(t) return t.Implements(reflect.TypeOf((*easyjson.Unmarshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*json.Unmarshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()) }
go
func hasCustomUnmarshaler(t reflect.Type) bool { t = reflect.PtrTo(t) return t.Implements(reflect.TypeOf((*easyjson.Unmarshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*json.Unmarshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()) }
[ "func", "hasCustomUnmarshaler", "(", "t", "reflect", ".", "Type", ")", "bool", "{", "t", "=", "reflect", ".", "PtrTo", "(", "t", ")", "\n", "return", "t", ".", "Implements", "(", "reflect", ".", "TypeOf", "(", "(", "*", "easyjson", ".", "Unmarshaler", ...
// returns true of the type t implements one of the custom unmarshaler interfaces
[ "returns", "true", "of", "the", "type", "t", "implements", "one", "of", "the", "custom", "unmarshaler", "interfaces" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/decoder.go#L90-L95
30,633
mailru/easyjson
opt/gotemplate_Float32.go
String
func (v Float32) String() string { if !v.Defined { return "<undefined>" } return fmt.Sprint(v.V) }
go
func (v Float32) String() string { if !v.Defined { return "<undefined>" } return fmt.Sprint(v.V) }
[ "func", "(", "v", "Float32", ")", "String", "(", ")", "string", "{", "if", "!", "v", ".", "Defined", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprint", "(", "v", ".", "V", ")", "\n", "}" ]
// String implements a stringer interface using fmt.Sprint for the value.
[ "String", "implements", "a", "stringer", "interface", "using", "fmt", ".", "Sprint", "for", "the", "value", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/opt/gotemplate_Float32.go#L74-L79
30,634
mailru/easyjson
gen/generator.go
NewGenerator
func NewGenerator(filename string) *Generator { ret := &Generator{ imports: map[string]string{ pkgWriter: "jwriter", pkgLexer: "jlexer", pkgEasyJSON: "easyjson", "encoding/json": "json", }, fieldNamer: DefaultFieldNamer{}, marshalers: make(map[reflect.Type]bool), typesSeen:...
go
func NewGenerator(filename string) *Generator { ret := &Generator{ imports: map[string]string{ pkgWriter: "jwriter", pkgLexer: "jlexer", pkgEasyJSON: "easyjson", "encoding/json": "json", }, fieldNamer: DefaultFieldNamer{}, marshalers: make(map[reflect.Type]bool), typesSeen:...
[ "func", "NewGenerator", "(", "filename", "string", ")", "*", "Generator", "{", "ret", ":=", "&", "Generator", "{", "imports", ":", "map", "[", "string", "]", "string", "{", "pkgWriter", ":", "\"", "\"", ",", "pkgLexer", ":", "\"", "\"", ",", "pkgEasyJS...
// NewGenerator initializes and returns a Generator.
[ "NewGenerator", "initializes", "and", "returns", "a", "Generator", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L59-L80
30,635
mailru/easyjson
gen/generator.go
SetPkg
func (g *Generator) SetPkg(name, path string) { g.pkgName = name g.pkgPath = path }
go
func (g *Generator) SetPkg(name, path string) { g.pkgName = name g.pkgPath = path }
[ "func", "(", "g", "*", "Generator", ")", "SetPkg", "(", "name", ",", "path", "string", ")", "{", "g", ".", "pkgName", "=", "name", "\n", "g", ".", "pkgPath", "=", "path", "\n", "}" ]
// SetPkg sets the name and path of output package.
[ "SetPkg", "sets", "the", "name", "and", "path", "of", "output", "package", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L83-L86
30,636
mailru/easyjson
gen/generator.go
printHeader
func (g *Generator) printHeader() { if g.buildTags != "" { fmt.Println("// +build ", g.buildTags) fmt.Println() } fmt.Println("// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.") fmt.Println() fmt.Println("package ", g.pkgName) fmt.Println() byAlias := map[string]string{} var aliases ...
go
func (g *Generator) printHeader() { if g.buildTags != "" { fmt.Println("// +build ", g.buildTags) fmt.Println() } fmt.Println("// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.") fmt.Println() fmt.Println("package ", g.pkgName) fmt.Println() byAlias := map[string]string{} var aliases ...
[ "func", "(", "g", "*", "Generator", ")", "printHeader", "(", ")", "{", "if", "g", ".", "buildTags", "!=", "\"", "\"", "{", "fmt", ".", "Println", "(", "\"", "\"", ",", "g", ".", "buildTags", ")", "\n", "fmt", ".", "Println", "(", ")", "\n", "}"...
// printHeader prints package declaration and imports.
[ "printHeader", "prints", "package", "declaration", "and", "imports", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L149-L183
30,637
mailru/easyjson
gen/generator.go
Run
func (g *Generator) Run(out io.Writer) error { g.out = &bytes.Buffer{} for len(g.typesUnseen) > 0 { t := g.typesUnseen[len(g.typesUnseen)-1] g.typesUnseen = g.typesUnseen[:len(g.typesUnseen)-1] g.typesSeen[t] = true if err := g.genDecoder(t); err != nil { return err } if err := g.genEncoder(t); err !...
go
func (g *Generator) Run(out io.Writer) error { g.out = &bytes.Buffer{} for len(g.typesUnseen) > 0 { t := g.typesUnseen[len(g.typesUnseen)-1] g.typesUnseen = g.typesUnseen[:len(g.typesUnseen)-1] g.typesSeen[t] = true if err := g.genDecoder(t); err != nil { return err } if err := g.genEncoder(t); err !...
[ "func", "(", "g", "*", "Generator", ")", "Run", "(", "out", "io", ".", "Writer", ")", "error", "{", "g", ".", "out", "=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "for", "len", "(", "g", ".", "typesUnseen", ")", ">", "0", "{", "t", ":="...
// Run runs the generator and outputs generated code to out.
[ "Run", "runs", "the", "generator", "and", "outputs", "generated", "code", "to", "out", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L186-L215
30,638
mailru/easyjson
gen/generator.go
fixPkgPathVendoring
func fixPkgPathVendoring(pkgPath string) string { const vendor = "/vendor/" if i := strings.LastIndex(pkgPath, vendor); i != -1 { return pkgPath[i+len(vendor):] } return pkgPath }
go
func fixPkgPathVendoring(pkgPath string) string { const vendor = "/vendor/" if i := strings.LastIndex(pkgPath, vendor); i != -1 { return pkgPath[i+len(vendor):] } return pkgPath }
[ "func", "fixPkgPathVendoring", "(", "pkgPath", "string", ")", "string", "{", "const", "vendor", "=", "\"", "\"", "\n", "if", "i", ":=", "strings", ".", "LastIndex", "(", "pkgPath", ",", "vendor", ")", ";", "i", "!=", "-", "1", "{", "return", "pkgPath",...
// fixes vendored paths
[ "fixes", "vendored", "paths" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L218-L224
30,639
mailru/easyjson
gen/generator.go
pkgAlias
func (g *Generator) pkgAlias(pkgPath string) string { pkgPath = fixPkgPathVendoring(pkgPath) if alias := g.imports[pkgPath]; alias != "" { return alias } for i := 0; ; i++ { alias := fixAliasName(path.Base(pkgPath)) if i > 0 { alias += fmt.Sprint(i) } exists := false for _, v := range g.imports { ...
go
func (g *Generator) pkgAlias(pkgPath string) string { pkgPath = fixPkgPathVendoring(pkgPath) if alias := g.imports[pkgPath]; alias != "" { return alias } for i := 0; ; i++ { alias := fixAliasName(path.Base(pkgPath)) if i > 0 { alias += fmt.Sprint(i) } exists := false for _, v := range g.imports { ...
[ "func", "(", "g", "*", "Generator", ")", "pkgAlias", "(", "pkgPath", "string", ")", "string", "{", "pkgPath", "=", "fixPkgPathVendoring", "(", "pkgPath", ")", "\n", "if", "alias", ":=", "g", ".", "imports", "[", "pkgPath", "]", ";", "alias", "!=", "\""...
// pkgAlias creates and returns and import alias for a given package.
[ "pkgAlias", "creates", "and", "returns", "and", "import", "alias", "for", "a", "given", "package", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L241-L266
30,640
mailru/easyjson
gen/generator.go
getType
func (g *Generator) getType(t reflect.Type) string { if t.Name() == "" { switch t.Kind() { case reflect.Ptr: return "*" + g.getType(t.Elem()) case reflect.Slice: return "[]" + g.getType(t.Elem()) case reflect.Array: return "[" + strconv.Itoa(t.Len()) + "]" + g.getType(t.Elem()) case reflect.Map: ...
go
func (g *Generator) getType(t reflect.Type) string { if t.Name() == "" { switch t.Kind() { case reflect.Ptr: return "*" + g.getType(t.Elem()) case reflect.Slice: return "[]" + g.getType(t.Elem()) case reflect.Array: return "[" + strconv.Itoa(t.Len()) + "]" + g.getType(t.Elem()) case reflect.Map: ...
[ "func", "(", "g", "*", "Generator", ")", "getType", "(", "t", "reflect", ".", "Type", ")", "string", "{", "if", "t", ".", "Name", "(", ")", "==", "\"", "\"", "{", "switch", "t", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Ptr", ":", ...
// getType return the textual type name of given type that can be used in generated code.
[ "getType", "return", "the", "textual", "type", "name", "of", "given", "type", "that", "can", "be", "used", "in", "generated", "code", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L269-L311
30,641
mailru/easyjson
gen/generator.go
escapeTag
func escapeTag(tag reflect.StructTag) string { t := string(tag) if strings.ContainsRune(t, '`') { // there are ` in the string; we can't use ` to enclose the string return strconv.Quote(t) } return "`" + t + "`" }
go
func escapeTag(tag reflect.StructTag) string { t := string(tag) if strings.ContainsRune(t, '`') { // there are ` in the string; we can't use ` to enclose the string return strconv.Quote(t) } return "`" + t + "`" }
[ "func", "escapeTag", "(", "tag", "reflect", ".", "StructTag", ")", "string", "{", "t", ":=", "string", "(", "tag", ")", "\n", "if", "strings", ".", "ContainsRune", "(", "t", ",", "'`'", ")", "{", "// there are ` in the string; we can't use ` to enclose the strin...
// escape a struct field tag string back to source code
[ "escape", "a", "struct", "field", "tag", "string", "back", "to", "source", "code" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L314-L321
30,642
mailru/easyjson
gen/generator.go
uniqueVarName
func (g *Generator) uniqueVarName() string { g.varCounter++ return fmt.Sprint("v", g.varCounter) }
go
func (g *Generator) uniqueVarName() string { g.varCounter++ return fmt.Sprint("v", g.varCounter) }
[ "func", "(", "g", "*", "Generator", ")", "uniqueVarName", "(", ")", "string", "{", "g", ".", "varCounter", "++", "\n", "return", "fmt", ".", "Sprint", "(", "\"", "\"", ",", "g", ".", "varCounter", ")", "\n", "}" ]
// uniqueVarName returns a file-unique name that can be used for generated variables.
[ "uniqueVarName", "returns", "a", "file", "-", "unique", "name", "that", "can", "be", "used", "for", "generated", "variables", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L324-L327
30,643
mailru/easyjson
gen/generator.go
lowerFirst
func lowerFirst(s string) string { if s == "" { return "" } str := "" strlen := len(s) /** Loop each char If is uppercase: If is first char, LOWER it If the following char is lower, LEAVE it If the following char is upper OR numeric, LOWER it If is the end of string, LEAVE it Else ...
go
func lowerFirst(s string) string { if s == "" { return "" } str := "" strlen := len(s) /** Loop each char If is uppercase: If is first char, LOWER it If the following char is lower, LEAVE it If the following char is upper OR numeric, LOWER it If is the end of string, LEAVE it Else ...
[ "func", "lowerFirst", "(", "s", "string", ")", "string", "{", "if", "s", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n\n", "str", ":=", "\"", "\"", "\n", "strlen", ":=", "len", "(", "s", ")", "\n\n", "/**\n\t Loop each char\n\t If is up...
// convert HTTPRestClient to httpRestClient
[ "convert", "HTTPRestClient", "to", "httpRestClient" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/generator.go#L408-L451
30,644
mailru/easyjson
gen/encoder.go
parseFieldTags
func parseFieldTags(f reflect.StructField) fieldTags { var ret fieldTags for i, s := range strings.Split(f.Tag.Get("json"), ",") { switch { case i == 0 && s == "-": ret.omit = true case i == 0: ret.name = s case s == "omitempty": ret.omitEmpty = true case s == "!omitempty": ret.noOmitEmpty = tr...
go
func parseFieldTags(f reflect.StructField) fieldTags { var ret fieldTags for i, s := range strings.Split(f.Tag.Get("json"), ",") { switch { case i == 0 && s == "-": ret.omit = true case i == 0: ret.name = s case s == "omitempty": ret.omitEmpty = true case s == "!omitempty": ret.noOmitEmpty = tr...
[ "func", "parseFieldTags", "(", "f", "reflect", ".", "StructField", ")", "fieldTags", "{", "var", "ret", "fieldTags", "\n\n", "for", "i", ",", "s", ":=", "range", "strings", ".", "Split", "(", "f", ".", "Tag", ".", "Get", "(", "\"", "\"", ")", ",", ...
// parseFieldTags parses the json field tag into a structure.
[ "parseFieldTags", "parses", "the", "json", "field", "tag", "into", "a", "structure", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/encoder.go#L64-L85
30,645
mailru/easyjson
gen/encoder.go
genTypeEncoder
func (g *Generator) genTypeEncoder(t reflect.Type, in string, tags fieldTags, indent int, assumeNonEmpty bool) error { ws := strings.Repeat(" ", indent) marshalerIface := reflect.TypeOf((*easyjson.Marshaler)(nil)).Elem() if reflect.PtrTo(t).Implements(marshalerIface) { fmt.Fprintln(g.out, ws+"("+in+").MarshalEas...
go
func (g *Generator) genTypeEncoder(t reflect.Type, in string, tags fieldTags, indent int, assumeNonEmpty bool) error { ws := strings.Repeat(" ", indent) marshalerIface := reflect.TypeOf((*easyjson.Marshaler)(nil)).Elem() if reflect.PtrTo(t).Implements(marshalerIface) { fmt.Fprintln(g.out, ws+"("+in+").MarshalEas...
[ "func", "(", "g", "*", "Generator", ")", "genTypeEncoder", "(", "t", "reflect", ".", "Type", ",", "in", "string", ",", "tags", "fieldTags", ",", "indent", "int", ",", "assumeNonEmpty", "bool", ")", "error", "{", "ws", ":=", "strings", ".", "Repeat", "(...
// genTypeEncoder generates code that encodes in of type t into the writer, but uses marshaler interface if implemented by t.
[ "genTypeEncoder", "generates", "code", "that", "encodes", "in", "of", "type", "t", "into", "the", "writer", "but", "uses", "marshaler", "interface", "if", "implemented", "by", "t", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/encoder.go#L88-L111
30,646
mailru/easyjson
gen/encoder.go
hasCustomMarshaler
func hasCustomMarshaler(t reflect.Type) bool { t = reflect.PtrTo(t) return t.Implements(reflect.TypeOf((*easyjson.Marshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*json.Marshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()) }
go
func hasCustomMarshaler(t reflect.Type) bool { t = reflect.PtrTo(t) return t.Implements(reflect.TypeOf((*easyjson.Marshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*json.Marshaler)(nil)).Elem()) || t.Implements(reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()) }
[ "func", "hasCustomMarshaler", "(", "t", "reflect", ".", "Type", ")", "bool", "{", "t", "=", "reflect", ".", "PtrTo", "(", "t", ")", "\n", "return", "t", ".", "Implements", "(", "reflect", ".", "TypeOf", "(", "(", "*", "easyjson", ".", "Marshaler", ")...
// returns true of the type t implements one of the custom marshaler interfaces
[ "returns", "true", "of", "the", "type", "t", "implements", "one", "of", "the", "custom", "marshaler", "interfaces" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/encoder.go#L114-L119
30,647
mailru/easyjson
gen/encoder.go
genTypeEncoderNoCheck
func (g *Generator) genTypeEncoderNoCheck(t reflect.Type, in string, tags fieldTags, indent int, assumeNonEmpty bool) error { ws := strings.Repeat(" ", indent) // Check whether type is primitive, needs to be done after interface check. if enc := primitiveStringEncoders[t.Kind()]; enc != "" && tags.asString { fmt...
go
func (g *Generator) genTypeEncoderNoCheck(t reflect.Type, in string, tags fieldTags, indent int, assumeNonEmpty bool) error { ws := strings.Repeat(" ", indent) // Check whether type is primitive, needs to be done after interface check. if enc := primitiveStringEncoders[t.Kind()]; enc != "" && tags.asString { fmt...
[ "func", "(", "g", "*", "Generator", ")", "genTypeEncoderNoCheck", "(", "t", "reflect", ".", "Type", ",", "in", "string", ",", "tags", "fieldTags", ",", "indent", "int", ",", "assumeNonEmpty", "bool", ")", "error", "{", "ws", ":=", "strings", ".", "Repeat...
// genTypeEncoderNoCheck generates code that encodes in of type t into the writer.
[ "genTypeEncoderNoCheck", "generates", "code", "that", "encodes", "in", "of", "type", "t", "into", "the", "writer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/gen/encoder.go#L122-L264
30,648
mailru/easyjson
bootstrap/bootstrap.go
writeMain
func (g *Generator) writeMain() (path string, err error) { f, err := ioutil.TempFile(filepath.Dir(g.OutName), "easyjson-bootstrap") if err != nil { return "", err } fmt.Fprintln(f, "// +build ignore") fmt.Fprintln(f) fmt.Fprintln(f, "// TEMPORARY AUTOGENERATED FILE: easyjson bootstapping code to launch") fmt....
go
func (g *Generator) writeMain() (path string, err error) { f, err := ioutil.TempFile(filepath.Dir(g.OutName), "easyjson-bootstrap") if err != nil { return "", err } fmt.Fprintln(f, "// +build ignore") fmt.Fprintln(f) fmt.Fprintln(f, "// TEMPORARY AUTOGENERATED FILE: easyjson bootstapping code to launch") fmt....
[ "func", "(", "g", "*", "Generator", ")", "writeMain", "(", ")", "(", "path", "string", ",", "err", "error", ")", "{", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "filepath", ".", "Dir", "(", "g", ".", "OutName", ")", ",", "\"", "\"", ...
// writeMain creates a .go file that launches the generator if 'go run'.
[ "writeMain", "creates", "a", ".", "go", "file", "that", "launches", "the", "generator", "if", "go", "run", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/bootstrap/bootstrap.go#L82-L146
30,649
mailru/easyjson
jwriter/writer.go
DumpTo
func (w *Writer) DumpTo(out io.Writer) (written int, err error) { return w.Buffer.DumpTo(out) }
go
func (w *Writer) DumpTo(out io.Writer) (written int, err error) { return w.Buffer.DumpTo(out) }
[ "func", "(", "w", "*", "Writer", ")", "DumpTo", "(", "out", "io", ".", "Writer", ")", "(", "written", "int", ",", "err", "error", ")", "{", "return", "w", ".", "Buffer", ".", "DumpTo", "(", "out", ")", "\n", "}" ]
// DumpTo outputs the data to given io.Writer, resetting the buffer.
[ "DumpTo", "outputs", "the", "data", "to", "given", "io", ".", "Writer", "resetting", "the", "buffer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jwriter/writer.go#L36-L38
30,650
mailru/easyjson
jwriter/writer.go
BuildBytes
func (w *Writer) BuildBytes(reuse ...[]byte) ([]byte, error) { if w.Error != nil { return nil, w.Error } return w.Buffer.BuildBytes(reuse...), nil }
go
func (w *Writer) BuildBytes(reuse ...[]byte) ([]byte, error) { if w.Error != nil { return nil, w.Error } return w.Buffer.BuildBytes(reuse...), nil }
[ "func", "(", "w", "*", "Writer", ")", "BuildBytes", "(", "reuse", "...", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "w", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "w", ".", "Error", "\n", "}", "\n\...
// BuildBytes returns writer data as a single byte slice. You can optionally provide one byte slice // as argument that it will try to reuse.
[ "BuildBytes", "returns", "writer", "data", "as", "a", "single", "byte", "slice", ".", "You", "can", "optionally", "provide", "one", "byte", "slice", "as", "argument", "that", "it", "will", "try", "to", "reuse", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jwriter/writer.go#L42-L48
30,651
mailru/easyjson
jwriter/writer.go
ReadCloser
func (w *Writer) ReadCloser() (io.ReadCloser, error) { if w.Error != nil { return nil, w.Error } return w.Buffer.ReadCloser(), nil }
go
func (w *Writer) ReadCloser() (io.ReadCloser, error) { if w.Error != nil { return nil, w.Error } return w.Buffer.ReadCloser(), nil }
[ "func", "(", "w", "*", "Writer", ")", "ReadCloser", "(", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "if", "w", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "w", ".", "Error", "\n", "}", "\n\n", "return", "w", ".", "Buff...
// ReadCloser returns an io.ReadCloser that can be used to read the data. // ReadCloser also resets the buffer.
[ "ReadCloser", "returns", "an", "io", ".", "ReadCloser", "that", "can", "be", "used", "to", "read", "the", "data", ".", "ReadCloser", "also", "resets", "the", "buffer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jwriter/writer.go#L52-L58
30,652
mailru/easyjson
jwriter/writer.go
Raw
func (w *Writer) Raw(data []byte, err error) { switch { case w.Error != nil: return case err != nil: w.Error = err case len(data) > 0: w.Buffer.AppendBytes(data) default: w.RawString("null") } }
go
func (w *Writer) Raw(data []byte, err error) { switch { case w.Error != nil: return case err != nil: w.Error = err case len(data) > 0: w.Buffer.AppendBytes(data) default: w.RawString("null") } }
[ "func", "(", "w", "*", "Writer", ")", "Raw", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "switch", "{", "case", "w", ".", "Error", "!=", "nil", ":", "return", "\n", "case", "err", "!=", "nil", ":", "w", ".", "Error", "=", "e...
// Raw appends raw binary data to the buffer or sets the error if it is given. Useful for // calling with results of MarshalJSON-like functions.
[ "Raw", "appends", "raw", "binary", "data", "to", "the", "buffer", "or", "sets", "the", "error", "if", "it", "is", "given", ".", "Useful", "for", "calling", "with", "results", "of", "MarshalJSON", "-", "like", "functions", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jwriter/writer.go#L72-L83
30,653
mailru/easyjson
jwriter/writer.go
RawText
func (w *Writer) RawText(data []byte, err error) { switch { case w.Error != nil: return case err != nil: w.Error = err case len(data) > 0: w.String(string(data)) default: w.RawString("null") } }
go
func (w *Writer) RawText(data []byte, err error) { switch { case w.Error != nil: return case err != nil: w.Error = err case len(data) > 0: w.String(string(data)) default: w.RawString("null") } }
[ "func", "(", "w", "*", "Writer", ")", "RawText", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "switch", "{", "case", "w", ".", "Error", "!=", "nil", ":", "return", "\n", "case", "err", "!=", "nil", ":", "w", ".", "Error", "=", ...
// RawText encloses raw binary data in quotes and appends in to the buffer. // Useful for calling with results of MarshalText-like functions.
[ "RawText", "encloses", "raw", "binary", "data", "in", "quotes", "and", "appends", "in", "to", "the", "buffer", ".", "Useful", "for", "calling", "with", "results", "of", "MarshalText", "-", "like", "functions", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jwriter/writer.go#L87-L98
30,654
mailru/easyjson
jwriter/writer.go
Base64Bytes
func (w *Writer) Base64Bytes(data []byte) { if data == nil { w.Buffer.AppendString("null") return } w.Buffer.AppendByte('"') w.base64(data) w.Buffer.AppendByte('"') }
go
func (w *Writer) Base64Bytes(data []byte) { if data == nil { w.Buffer.AppendString("null") return } w.Buffer.AppendByte('"') w.base64(data) w.Buffer.AppendByte('"') }
[ "func", "(", "w", "*", "Writer", ")", "Base64Bytes", "(", "data", "[", "]", "byte", ")", "{", "if", "data", "==", "nil", "{", "w", ".", "Buffer", ".", "AppendString", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "w", ".", "Buffer", "....
// Base64Bytes appends data to the buffer after base64 encoding it
[ "Base64Bytes", "appends", "data", "to", "the", "buffer", "after", "base64", "encoding", "it" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jwriter/writer.go#L101-L109
30,655
mailru/easyjson
parser/pkgpath.go
goModPath
func goModPath(fname string, isDir bool) (string, error) { root := fname if !isDir { root = filepath.Dir(fname) } goModPathCache.RLock() goModPath, ok := goModPathCache.paths[root] goModPathCache.RUnlock() if ok { return goModPath, nil } defer func() { goModPathCache.Lock() goModPathCache.paths[root]...
go
func goModPath(fname string, isDir bool) (string, error) { root := fname if !isDir { root = filepath.Dir(fname) } goModPathCache.RLock() goModPath, ok := goModPathCache.paths[root] goModPathCache.RUnlock() if ok { return goModPath, nil } defer func() { goModPathCache.Lock() goModPathCache.paths[root]...
[ "func", "goModPath", "(", "fname", "string", ",", "isDir", "bool", ")", "(", "string", ",", "error", ")", "{", "root", ":=", "fname", "\n", "if", "!", "isDir", "{", "root", "=", "filepath", ".", "Dir", "(", "fname", ")", "\n", "}", "\n\n", "goModPa...
// empty if no go.mod, GO111MODULE=off or go without go modules support
[ "empty", "if", "no", "go", ".", "mod", "GO111MODULE", "=", "off", "or", "go", "without", "go", "modules", "support" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/parser/pkgpath.go#L46-L76
30,656
mailru/easyjson
buffer/pool.go
putBuf
func putBuf(buf []byte) { size := cap(buf) if size < config.PooledSize { return } if c := buffers[size]; c != nil { c.Put(buf[:0]) } }
go
func putBuf(buf []byte) { size := cap(buf) if size < config.PooledSize { return } if c := buffers[size]; c != nil { c.Put(buf[:0]) } }
[ "func", "putBuf", "(", "buf", "[", "]", "byte", ")", "{", "size", ":=", "cap", "(", "buf", ")", "\n", "if", "size", "<", "config", ".", "PooledSize", "{", "return", "\n", "}", "\n", "if", "c", ":=", "buffers", "[", "size", "]", ";", "c", "!=", ...
// putBuf puts a chunk to reuse pool if it can be reused.
[ "putBuf", "puts", "a", "chunk", "to", "reuse", "pool", "if", "it", "can", "be", "reused", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L43-L51
30,657
mailru/easyjson
buffer/pool.go
getBuf
func getBuf(size int) []byte { if size < config.PooledSize { return make([]byte, 0, size) } if c := buffers[size]; c != nil { v := c.Get() if v != nil { return v.([]byte) } } return make([]byte, 0, size) }
go
func getBuf(size int) []byte { if size < config.PooledSize { return make([]byte, 0, size) } if c := buffers[size]; c != nil { v := c.Get() if v != nil { return v.([]byte) } } return make([]byte, 0, size) }
[ "func", "getBuf", "(", "size", "int", ")", "[", "]", "byte", "{", "if", "size", "<", "config", ".", "PooledSize", "{", "return", "make", "(", "[", "]", "byte", ",", "0", ",", "size", ")", "\n", "}", "\n\n", "if", "c", ":=", "buffers", "[", "siz...
// getBuf gets a chunk from reuse pool or creates a new one if reuse failed.
[ "getBuf", "gets", "a", "chunk", "from", "reuse", "pool", "or", "creates", "a", "new", "one", "if", "reuse", "failed", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L54-L66
30,658
mailru/easyjson
buffer/pool.go
EnsureSpace
func (b *Buffer) EnsureSpace(s int) { if cap(b.Buf)-len(b.Buf) >= s { return } l := len(b.Buf) if l > 0 { if cap(b.toPool) != cap(b.Buf) { // Chunk was reallocated, toPool can be pooled. putBuf(b.toPool) } if cap(b.bufs) == 0 { b.bufs = make([][]byte, 0, 8) } b.bufs = append(b.bufs, b.Buf) l ...
go
func (b *Buffer) EnsureSpace(s int) { if cap(b.Buf)-len(b.Buf) >= s { return } l := len(b.Buf) if l > 0 { if cap(b.toPool) != cap(b.Buf) { // Chunk was reallocated, toPool can be pooled. putBuf(b.toPool) } if cap(b.bufs) == 0 { b.bufs = make([][]byte, 0, 8) } b.bufs = append(b.bufs, b.Buf) l ...
[ "func", "(", "b", "*", "Buffer", ")", "EnsureSpace", "(", "s", "int", ")", "{", "if", "cap", "(", "b", ".", "Buf", ")", "-", "len", "(", "b", ".", "Buf", ")", ">=", "s", "{", "return", "\n", "}", "\n", "l", ":=", "len", "(", "b", ".", "Bu...
// EnsureSpace makes sure that the current chunk contains at least s free bytes, // possibly creating a new chunk.
[ "EnsureSpace", "makes", "sure", "that", "the", "current", "chunk", "contains", "at", "least", "s", "free", "bytes", "possibly", "creating", "a", "new", "chunk", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L80-L104
30,659
mailru/easyjson
buffer/pool.go
AppendByte
func (b *Buffer) AppendByte(data byte) { if cap(b.Buf) == len(b.Buf) { // EnsureSpace won't be inlined. b.EnsureSpace(1) } b.Buf = append(b.Buf, data) }
go
func (b *Buffer) AppendByte(data byte) { if cap(b.Buf) == len(b.Buf) { // EnsureSpace won't be inlined. b.EnsureSpace(1) } b.Buf = append(b.Buf, data) }
[ "func", "(", "b", "*", "Buffer", ")", "AppendByte", "(", "data", "byte", ")", "{", "if", "cap", "(", "b", ".", "Buf", ")", "==", "len", "(", "b", ".", "Buf", ")", "{", "// EnsureSpace won't be inlined.", "b", ".", "EnsureSpace", "(", "1", ")", "\n"...
// AppendByte appends a single byte to buffer.
[ "AppendByte", "appends", "a", "single", "byte", "to", "buffer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L107-L112
30,660
mailru/easyjson
buffer/pool.go
AppendBytes
func (b *Buffer) AppendBytes(data []byte) { for len(data) > 0 { if cap(b.Buf) == len(b.Buf) { // EnsureSpace won't be inlined. b.EnsureSpace(1) } sz := cap(b.Buf) - len(b.Buf) if sz > len(data) { sz = len(data) } b.Buf = append(b.Buf, data[:sz]...) data = data[sz:] } }
go
func (b *Buffer) AppendBytes(data []byte) { for len(data) > 0 { if cap(b.Buf) == len(b.Buf) { // EnsureSpace won't be inlined. b.EnsureSpace(1) } sz := cap(b.Buf) - len(b.Buf) if sz > len(data) { sz = len(data) } b.Buf = append(b.Buf, data[:sz]...) data = data[sz:] } }
[ "func", "(", "b", "*", "Buffer", ")", "AppendBytes", "(", "data", "[", "]", "byte", ")", "{", "for", "len", "(", "data", ")", ">", "0", "{", "if", "cap", "(", "b", ".", "Buf", ")", "==", "len", "(", "b", ".", "Buf", ")", "{", "// EnsureSpace ...
// AppendBytes appends a byte slice to buffer.
[ "AppendBytes", "appends", "a", "byte", "slice", "to", "buffer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L115-L129
30,661
mailru/easyjson
buffer/pool.go
AppendString
func (b *Buffer) AppendString(data string) { for len(data) > 0 { if cap(b.Buf) == len(b.Buf) { // EnsureSpace won't be inlined. b.EnsureSpace(1) } sz := cap(b.Buf) - len(b.Buf) if sz > len(data) { sz = len(data) } b.Buf = append(b.Buf, data[:sz]...) data = data[sz:] } }
go
func (b *Buffer) AppendString(data string) { for len(data) > 0 { if cap(b.Buf) == len(b.Buf) { // EnsureSpace won't be inlined. b.EnsureSpace(1) } sz := cap(b.Buf) - len(b.Buf) if sz > len(data) { sz = len(data) } b.Buf = append(b.Buf, data[:sz]...) data = data[sz:] } }
[ "func", "(", "b", "*", "Buffer", ")", "AppendString", "(", "data", "string", ")", "{", "for", "len", "(", "data", ")", ">", "0", "{", "if", "cap", "(", "b", ".", "Buf", ")", "==", "len", "(", "b", ".", "Buf", ")", "{", "// EnsureSpace won't be in...
// AppendBytes appends a string to buffer.
[ "AppendBytes", "appends", "a", "string", "to", "buffer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L132-L146
30,662
mailru/easyjson
buffer/pool.go
Size
func (b *Buffer) Size() int { size := len(b.Buf) for _, buf := range b.bufs { size += len(buf) } return size }
go
func (b *Buffer) Size() int { size := len(b.Buf) for _, buf := range b.bufs { size += len(buf) } return size }
[ "func", "(", "b", "*", "Buffer", ")", "Size", "(", ")", "int", "{", "size", ":=", "len", "(", "b", ".", "Buf", ")", "\n", "for", "_", ",", "buf", ":=", "range", "b", ".", "bufs", "{", "size", "+=", "len", "(", "buf", ")", "\n", "}", "\n", ...
// Size computes the size of a buffer by adding sizes of every chunk.
[ "Size", "computes", "the", "size", "of", "a", "buffer", "by", "adding", "sizes", "of", "every", "chunk", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L149-L155
30,663
mailru/easyjson
buffer/pool.go
DumpTo
func (b *Buffer) DumpTo(w io.Writer) (written int, err error) { var n int for _, buf := range b.bufs { if err == nil { n, err = w.Write(buf) written += n } putBuf(buf) } if err == nil { n, err = w.Write(b.Buf) written += n } putBuf(b.toPool) b.bufs = nil b.Buf = nil b.toPool = nil return }
go
func (b *Buffer) DumpTo(w io.Writer) (written int, err error) { var n int for _, buf := range b.bufs { if err == nil { n, err = w.Write(buf) written += n } putBuf(buf) } if err == nil { n, err = w.Write(b.Buf) written += n } putBuf(b.toPool) b.bufs = nil b.Buf = nil b.toPool = nil return }
[ "func", "(", "b", "*", "Buffer", ")", "DumpTo", "(", "w", "io", ".", "Writer", ")", "(", "written", "int", ",", "err", "error", ")", "{", "var", "n", "int", "\n", "for", "_", ",", "buf", ":=", "range", "b", ".", "bufs", "{", "if", "err", "=="...
// DumpTo outputs the contents of a buffer to a writer and resets the buffer.
[ "DumpTo", "outputs", "the", "contents", "of", "a", "buffer", "to", "a", "writer", "and", "resets", "the", "buffer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L158-L179
30,664
mailru/easyjson
buffer/pool.go
BuildBytes
func (b *Buffer) BuildBytes(reuse ...[]byte) []byte { if len(b.bufs) == 0 { ret := b.Buf b.toPool = nil b.Buf = nil return ret } var ret []byte size := b.Size() // If we got a buffer as argument and it is big enought, reuse it. if len(reuse) == 1 && cap(reuse[0]) >= size { ret = reuse[0][:0] } else {...
go
func (b *Buffer) BuildBytes(reuse ...[]byte) []byte { if len(b.bufs) == 0 { ret := b.Buf b.toPool = nil b.Buf = nil return ret } var ret []byte size := b.Size() // If we got a buffer as argument and it is big enought, reuse it. if len(reuse) == 1 && cap(reuse[0]) >= size { ret = reuse[0][:0] } else {...
[ "func", "(", "b", "*", "Buffer", ")", "BuildBytes", "(", "reuse", "...", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "len", "(", "b", ".", "bufs", ")", "==", "0", "{", "ret", ":=", "b", ".", "Buf", "\n", "b", ".", "toPool", "=", "ni...
// BuildBytes creates a single byte slice with all the contents of the buffer. Data is // copied if it does not fit in a single chunk. You can optionally provide one byte // slice as argument that it will try to reuse.
[ "BuildBytes", "creates", "a", "single", "byte", "slice", "with", "all", "the", "contents", "of", "the", "buffer", ".", "Data", "is", "copied", "if", "it", "does", "not", "fit", "in", "a", "single", "chunk", ".", "You", "can", "optionally", "provide", "on...
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L184-L214
30,665
mailru/easyjson
buffer/pool.go
ReadCloser
func (b *Buffer) ReadCloser() io.ReadCloser { ret := &readCloser{0, append(b.bufs, b.Buf)} b.bufs = nil b.toPool = nil b.Buf = nil return ret }
go
func (b *Buffer) ReadCloser() io.ReadCloser { ret := &readCloser{0, append(b.bufs, b.Buf)} b.bufs = nil b.toPool = nil b.Buf = nil return ret }
[ "func", "(", "b", "*", "Buffer", ")", "ReadCloser", "(", ")", "io", ".", "ReadCloser", "{", "ret", ":=", "&", "readCloser", "{", "0", ",", "append", "(", "b", ".", "bufs", ",", "b", ".", "Buf", ")", "}", "\n\n", "b", ".", "bufs", "=", "nil", ...
// ReadCloser creates an io.ReadCloser with all the contents of the buffer.
[ "ReadCloser", "creates", "an", "io", ".", "ReadCloser", "with", "all", "the", "contents", "of", "the", "buffer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/buffer/pool.go#L262-L270
30,666
mailru/easyjson
jlexer/lexer.go
FetchToken
func (r *Lexer) FetchToken() { r.token.kind = tokenUndef r.start = r.pos // Check if r.Data has r.pos element // If it doesn't, it mean corrupted input data if len(r.Data) < r.pos { r.errParse("Unexpected end of data") return } // Determine the type of a token by skipping whitespace and reading the // firs...
go
func (r *Lexer) FetchToken() { r.token.kind = tokenUndef r.start = r.pos // Check if r.Data has r.pos element // If it doesn't, it mean corrupted input data if len(r.Data) < r.pos { r.errParse("Unexpected end of data") return } // Determine the type of a token by skipping whitespace and reading the // firs...
[ "func", "(", "r", "*", "Lexer", ")", "FetchToken", "(", ")", "{", "r", ".", "token", ".", "kind", "=", "tokenUndef", "\n", "r", ".", "start", "=", "r", ".", "pos", "\n\n", "// Check if r.Data has r.pos element", "// If it doesn't, it mean corrupted input data", ...
// FetchToken scans the input for the next token.
[ "FetchToken", "scans", "the", "input", "for", "the", "next", "token", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L57-L157
30,667
mailru/easyjson
jlexer/lexer.go
isTokenEnd
func isTokenEnd(c byte) bool { return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '[' || c == ']' || c == '{' || c == '}' || c == ',' || c == ':' }
go
func isTokenEnd(c byte) bool { return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '[' || c == ']' || c == '{' || c == '}' || c == ',' || c == ':' }
[ "func", "isTokenEnd", "(", "c", "byte", ")", "bool", "{", "return", "c", "==", "' '", "||", "c", "==", "'\\t'", "||", "c", "==", "'\\r'", "||", "c", "==", "'\\n'", "||", "c", "==", "'['", "||", "c", "==", "']'", "||", "c", "==", "'{'", "||", ...
// isTokenEnd returns true if the char can follow a non-delimiter token
[ "isTokenEnd", "returns", "true", "if", "the", "char", "can", "follow", "a", "non", "-", "delimiter", "token" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L160-L162
30,668
mailru/easyjson
jlexer/lexer.go
fetchNull
func (r *Lexer) fetchNull() { r.pos += 4 if r.pos > len(r.Data) || r.Data[r.pos-3] != 'u' || r.Data[r.pos-2] != 'l' || r.Data[r.pos-1] != 'l' || (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { r.pos -= 4 r.errSyntax() } }
go
func (r *Lexer) fetchNull() { r.pos += 4 if r.pos > len(r.Data) || r.Data[r.pos-3] != 'u' || r.Data[r.pos-2] != 'l' || r.Data[r.pos-1] != 'l' || (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { r.pos -= 4 r.errSyntax() } }
[ "func", "(", "r", "*", "Lexer", ")", "fetchNull", "(", ")", "{", "r", ".", "pos", "+=", "4", "\n", "if", "r", ".", "pos", ">", "len", "(", "r", ".", "Data", ")", "||", "r", ".", "Data", "[", "r", ".", "pos", "-", "3", "]", "!=", "'u'", ...
// fetchNull fetches and checks remaining bytes of null keyword.
[ "fetchNull", "fetches", "and", "checks", "remaining", "bytes", "of", "null", "keyword", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L165-L176
30,669
mailru/easyjson
jlexer/lexer.go
fetchTrue
func (r *Lexer) fetchTrue() { r.pos += 4 if r.pos > len(r.Data) || r.Data[r.pos-3] != 'r' || r.Data[r.pos-2] != 'u' || r.Data[r.pos-1] != 'e' || (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { r.pos -= 4 r.errSyntax() } }
go
func (r *Lexer) fetchTrue() { r.pos += 4 if r.pos > len(r.Data) || r.Data[r.pos-3] != 'r' || r.Data[r.pos-2] != 'u' || r.Data[r.pos-1] != 'e' || (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { r.pos -= 4 r.errSyntax() } }
[ "func", "(", "r", "*", "Lexer", ")", "fetchTrue", "(", ")", "{", "r", ".", "pos", "+=", "4", "\n", "if", "r", ".", "pos", ">", "len", "(", "r", ".", "Data", ")", "||", "r", ".", "Data", "[", "r", ".", "pos", "-", "3", "]", "!=", "'r'", ...
// fetchTrue fetches and checks remaining bytes of true keyword.
[ "fetchTrue", "fetches", "and", "checks", "remaining", "bytes", "of", "true", "keyword", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L179-L190
30,670
mailru/easyjson
jlexer/lexer.go
fetchFalse
func (r *Lexer) fetchFalse() { r.pos += 5 if r.pos > len(r.Data) || r.Data[r.pos-4] != 'a' || r.Data[r.pos-3] != 'l' || r.Data[r.pos-2] != 's' || r.Data[r.pos-1] != 'e' || (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { r.pos -= 5 r.errSyntax() } }
go
func (r *Lexer) fetchFalse() { r.pos += 5 if r.pos > len(r.Data) || r.Data[r.pos-4] != 'a' || r.Data[r.pos-3] != 'l' || r.Data[r.pos-2] != 's' || r.Data[r.pos-1] != 'e' || (r.pos != len(r.Data) && !isTokenEnd(r.Data[r.pos])) { r.pos -= 5 r.errSyntax() } }
[ "func", "(", "r", "*", "Lexer", ")", "fetchFalse", "(", ")", "{", "r", ".", "pos", "+=", "5", "\n", "if", "r", ".", "pos", ">", "len", "(", "r", ".", "Data", ")", "||", "r", ".", "Data", "[", "r", ".", "pos", "-", "4", "]", "!=", "'a'", ...
// fetchFalse fetches and checks remaining bytes of false keyword.
[ "fetchFalse", "fetches", "and", "checks", "remaining", "bytes", "of", "false", "keyword", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L193-L205
30,671
mailru/easyjson
jlexer/lexer.go
fetchNumber
func (r *Lexer) fetchNumber() { hasE := false afterE := false hasDot := false r.pos++ for i, c := range r.Data[r.pos:] { switch { case c >= '0' && c <= '9': afterE = false case c == '.' && !hasDot: hasDot = true case (c == 'e' || c == 'E') && !hasE: hasE = true hasDot = true afterE = true ...
go
func (r *Lexer) fetchNumber() { hasE := false afterE := false hasDot := false r.pos++ for i, c := range r.Data[r.pos:] { switch { case c >= '0' && c <= '9': afterE = false case c == '.' && !hasDot: hasDot = true case (c == 'e' || c == 'E') && !hasE: hasE = true hasDot = true afterE = true ...
[ "func", "(", "r", "*", "Lexer", ")", "fetchNumber", "(", ")", "{", "hasE", ":=", "false", "\n", "afterE", ":=", "false", "\n", "hasDot", ":=", "false", "\n\n", "r", ".", "pos", "++", "\n", "for", "i", ",", "c", ":=", "range", "r", ".", "Data", ...
// fetchNumber scans a number literal token.
[ "fetchNumber", "scans", "a", "number", "literal", "token", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L208-L239
30,672
mailru/easyjson
jlexer/lexer.go
findStringLen
func findStringLen(data []byte) (isValid, hasEscapes bool, length int) { delta := 0 for i := 0; i < len(data); i++ { switch data[i] { case '\\': i++ delta++ if i < len(data) && data[i] == 'u' { delta++ } case '"': return true, (delta > 0), (i - delta) } } return false, false, len(data) ...
go
func findStringLen(data []byte) (isValid, hasEscapes bool, length int) { delta := 0 for i := 0; i < len(data); i++ { switch data[i] { case '\\': i++ delta++ if i < len(data) && data[i] == 'u' { delta++ } case '"': return true, (delta > 0), (i - delta) } } return false, false, len(data) ...
[ "func", "findStringLen", "(", "data", "[", "]", "byte", ")", "(", "isValid", ",", "hasEscapes", "bool", ",", "length", "int", ")", "{", "delta", ":=", "0", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "data", ")", ";", "i", "++", "...
// findStringLen tries to scan into the string literal for ending quote char to determine required size. // The size will be exact if no escapes are present and may be inexact if there are escaped chars.
[ "findStringLen", "tries", "to", "scan", "into", "the", "string", "literal", "for", "ending", "quote", "char", "to", "determine", "required", "size", ".", "The", "size", "will", "be", "exact", "if", "no", "escapes", "are", "present", "and", "may", "be", "in...
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L243-L260
30,673
mailru/easyjson
jlexer/lexer.go
processEscape
func (r *Lexer) processEscape(data []byte) (int, error) { if len(data) < 2 { return 0, fmt.Errorf("syntax error at %v", string(data)) } c := data[1] switch c { case '"', '/', '\\': r.token.byteValue = append(r.token.byteValue, c) return 2, nil case 'b': r.token.byteValue = append(r.token.byteValue, '\b')...
go
func (r *Lexer) processEscape(data []byte) (int, error) { if len(data) < 2 { return 0, fmt.Errorf("syntax error at %v", string(data)) } c := data[1] switch c { case '"', '/', '\\': r.token.byteValue = append(r.token.byteValue, c) return 2, nil case 'b': r.token.byteValue = append(r.token.byteValue, '\b')...
[ "func", "(", "r", "*", "Lexer", ")", "processEscape", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "len", "(", "data", ")", "<", "2", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "strin...
// processEscape processes a single escape sequence and returns number of bytes processed.
[ "processEscape", "processes", "a", "single", "escape", "sequence", "and", "returns", "number", "of", "bytes", "processed", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L290-L338
30,674
mailru/easyjson
jlexer/lexer.go
fetchString
func (r *Lexer) fetchString() { r.pos++ data := r.Data[r.pos:] isValid, hasEscapes, length := findStringLen(data) if !isValid { r.pos += length r.errParse("unterminated string literal") return } if !hasEscapes { r.token.byteValue = data[:length] r.pos += length + 1 return } r.token.byteValue = mak...
go
func (r *Lexer) fetchString() { r.pos++ data := r.Data[r.pos:] isValid, hasEscapes, length := findStringLen(data) if !isValid { r.pos += length r.errParse("unterminated string literal") return } if !hasEscapes { r.token.byteValue = data[:length] r.pos += length + 1 return } r.token.byteValue = mak...
[ "func", "(", "r", "*", "Lexer", ")", "fetchString", "(", ")", "{", "r", ".", "pos", "++", "\n", "data", ":=", "r", ".", "Data", "[", "r", ".", "pos", ":", "]", "\n\n", "isValid", ",", "hasEscapes", ",", "length", ":=", "findStringLen", "(", "data...
// fetchString scans a string literal token.
[ "fetchString", "scans", "a", "string", "literal", "token", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L341-L382
30,675
mailru/easyjson
jlexer/lexer.go
scanToken
func (r *Lexer) scanToken() { if r.token.kind != tokenUndef || r.fatalError != nil { return } r.FetchToken() }
go
func (r *Lexer) scanToken() { if r.token.kind != tokenUndef || r.fatalError != nil { return } r.FetchToken() }
[ "func", "(", "r", "*", "Lexer", ")", "scanToken", "(", ")", "{", "if", "r", ".", "token", ".", "kind", "!=", "tokenUndef", "||", "r", ".", "fatalError", "!=", "nil", "{", "return", "\n", "}", "\n\n", "r", ".", "FetchToken", "(", ")", "\n", "}" ]
// scanToken scans the next token if no token is currently available in the lexer.
[ "scanToken", "scans", "the", "next", "token", "if", "no", "token", "is", "currently", "available", "in", "the", "lexer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L385-L391
30,676
mailru/easyjson
jlexer/lexer.go
consume
func (r *Lexer) consume() { r.token.kind = tokenUndef r.token.delimValue = 0 }
go
func (r *Lexer) consume() { r.token.kind = tokenUndef r.token.delimValue = 0 }
[ "func", "(", "r", "*", "Lexer", ")", "consume", "(", ")", "{", "r", ".", "token", ".", "kind", "=", "tokenUndef", "\n", "r", ".", "token", ".", "delimValue", "=", "0", "\n", "}" ]
// consume resets the current token to allow scanning the next one.
[ "consume", "resets", "the", "current", "token", "to", "allow", "scanning", "the", "next", "one", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L394-L397
30,677
mailru/easyjson
jlexer/lexer.go
Delim
func (r *Lexer) Delim(c byte) { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.delimValue != c { r.consume() // errInvalidToken can change token if UseMultipleErrors is enabled. r.errInvalidToken(string([]byte{c})) } else { r.consume() } }
go
func (r *Lexer) Delim(c byte) { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.delimValue != c { r.consume() // errInvalidToken can change token if UseMultipleErrors is enabled. r.errInvalidToken(string([]byte{c})) } else { r.consume() } }
[ "func", "(", "r", "*", "Lexer", ")", "Delim", "(", "c", "byte", ")", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n\n", "if", "!", "r", "....
// Delim consumes a token and verifies that it is the given delimiter.
[ "Delim", "consumes", "a", "token", "and", "verifies", "that", "it", "is", "the", "given", "delimiter", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L468-L479
30,678
mailru/easyjson
jlexer/lexer.go
IsDelim
func (r *Lexer) IsDelim(c byte) bool { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } return !r.Ok() || r.token.delimValue == c }
go
func (r *Lexer) IsDelim(c byte) bool { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } return !r.Ok() || r.token.delimValue == c }
[ "func", "(", "r", "*", "Lexer", ")", "IsDelim", "(", "c", "byte", ")", "bool", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n", "return", "!...
// IsDelim returns true if there was no scanning error and next token is the given delimiter.
[ "IsDelim", "returns", "true", "if", "there", "was", "no", "scanning", "error", "and", "next", "token", "is", "the", "given", "delimiter", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L482-L487
30,679
mailru/easyjson
jlexer/lexer.go
Null
func (r *Lexer) Null() { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenNull { r.errInvalidToken("null") } r.consume() }
go
func (r *Lexer) Null() { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenNull { r.errInvalidToken("null") } r.consume() }
[ "func", "(", "r", "*", "Lexer", ")", "Null", "(", ")", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n", "if", "!", "r", ".", "Ok", "(", ...
// Null verifies that the next token is null and consumes it.
[ "Null", "verifies", "that", "the", "next", "token", "is", "null", "and", "consumes", "it", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L490-L498
30,680
mailru/easyjson
jlexer/lexer.go
IsNull
func (r *Lexer) IsNull() bool { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } return r.Ok() && r.token.kind == tokenNull }
go
func (r *Lexer) IsNull() bool { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } return r.Ok() && r.token.kind == tokenNull }
[ "func", "(", "r", "*", "Lexer", ")", "IsNull", "(", ")", "bool", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n", "return", "r", ".", "Ok", ...
// IsNull returns true if the next token is a null keyword.
[ "IsNull", "returns", "true", "if", "the", "next", "token", "is", "a", "null", "keyword", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L501-L506
30,681
mailru/easyjson
jlexer/lexer.go
Skip
func (r *Lexer) Skip() { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } r.consume() }
go
func (r *Lexer) Skip() { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } r.consume() }
[ "func", "(", "r", "*", "Lexer", ")", "Skip", "(", ")", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n", "r", ".", "consume", "(", ")", "\n...
// Skip skips a single token.
[ "Skip", "skips", "a", "single", "token", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L509-L514
30,682
mailru/easyjson
jlexer/lexer.go
Raw
func (r *Lexer) Raw() []byte { r.SkipRecursive() if !r.Ok() { return nil } return r.Data[r.start:r.pos] }
go
func (r *Lexer) Raw() []byte { r.SkipRecursive() if !r.Ok() { return nil } return r.Data[r.start:r.pos] }
[ "func", "(", "r", "*", "Lexer", ")", "Raw", "(", ")", "[", "]", "byte", "{", "r", ".", "SkipRecursive", "(", ")", "\n", "if", "!", "r", ".", "Ok", "(", ")", "{", "return", "nil", "\n", "}", "\n", "return", "r", ".", "Data", "[", "r", ".", ...
// Raw fetches the next item recursively as a data slice
[ "Raw", "fetches", "the", "next", "item", "recursively", "as", "a", "data", "slice" ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L569-L575
30,683
mailru/easyjson
jlexer/lexer.go
Consumed
func (r *Lexer) Consumed() { if r.pos > len(r.Data) || !r.Ok() { return } for _, c := range r.Data[r.pos:] { if c != ' ' && c != '\t' && c != '\r' && c != '\n' { r.AddError(&LexerError{ Reason: "invalid character '" + string(c) + "' after top-level value", Offset: r.pos, Data: string(r.Data[r.p...
go
func (r *Lexer) Consumed() { if r.pos > len(r.Data) || !r.Ok() { return } for _, c := range r.Data[r.pos:] { if c != ' ' && c != '\t' && c != '\r' && c != '\n' { r.AddError(&LexerError{ Reason: "invalid character '" + string(c) + "' after top-level value", Offset: r.pos, Data: string(r.Data[r.p...
[ "func", "(", "r", "*", "Lexer", ")", "Consumed", "(", ")", "{", "if", "r", ".", "pos", ">", "len", "(", "r", ".", "Data", ")", "||", "!", "r", ".", "Ok", "(", ")", "{", "return", "\n", "}", "\n\n", "for", "_", ",", "c", ":=", "range", "r"...
// Consumed reads all remaining bytes from the input, publishing an error if // there is anything but whitespace remaining.
[ "Consumed", "reads", "all", "remaining", "bytes", "from", "the", "input", "publishing", "an", "error", "if", "there", "is", "anything", "but", "whitespace", "remaining", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L585-L603
30,684
mailru/easyjson
jlexer/lexer.go
String
func (r *Lexer) String() string { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenString { r.errInvalidToken("string") return "" } ret := string(r.token.byteValue) r.consume() return ret }
go
func (r *Lexer) String() string { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenString { r.errInvalidToken("string") return "" } ret := string(r.token.byteValue) r.consume() return ret }
[ "func", "(", "r", "*", "Lexer", ")", "String", "(", ")", "string", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n", "if", "!", "r", ".", "...
// String reads a string literal.
[ "String", "reads", "a", "string", "literal", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L635-L646
30,685
mailru/easyjson
jlexer/lexer.go
Bytes
func (r *Lexer) Bytes() []byte { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenString { r.errInvalidToken("string") return nil } ret := make([]byte, base64.StdEncoding.DecodedLen(len(r.token.byteValue))) n, err := base64.StdEncoding.Decode(ret, r.token.byteVal...
go
func (r *Lexer) Bytes() []byte { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenString { r.errInvalidToken("string") return nil } ret := make([]byte, base64.StdEncoding.DecodedLen(len(r.token.byteValue))) n, err := base64.StdEncoding.Decode(ret, r.token.byteVal...
[ "func", "(", "r", "*", "Lexer", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n", "if", "!", "r",...
// Bytes reads a string literal and base64 decodes it into a byte slice.
[ "Bytes", "reads", "a", "string", "literal", "and", "base64", "decodes", "it", "into", "a", "byte", "slice", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L649-L668
30,686
mailru/easyjson
jlexer/lexer.go
Bool
func (r *Lexer) Bool() bool { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenBool { r.errInvalidToken("bool") return false } ret := r.token.boolValue r.consume() return ret }
go
func (r *Lexer) Bool() bool { if r.token.kind == tokenUndef && r.Ok() { r.FetchToken() } if !r.Ok() || r.token.kind != tokenBool { r.errInvalidToken("bool") return false } ret := r.token.boolValue r.consume() return ret }
[ "func", "(", "r", "*", "Lexer", ")", "Bool", "(", ")", "bool", "{", "if", "r", ".", "token", ".", "kind", "==", "tokenUndef", "&&", "r", ".", "Ok", "(", ")", "{", "r", ".", "FetchToken", "(", ")", "\n", "}", "\n", "if", "!", "r", ".", "Ok",...
// Bool reads a true or false boolean keyword.
[ "Bool", "reads", "a", "true", "or", "false", "boolean", "keyword", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L671-L682
30,687
mailru/easyjson
helpers.go
Marshal
func Marshal(v Marshaler) ([]byte, error) { w := jwriter.Writer{} v.MarshalEasyJSON(&w) return w.BuildBytes() }
go
func Marshal(v Marshaler) ([]byte, error) { w := jwriter.Writer{} v.MarshalEasyJSON(&w) return w.BuildBytes() }
[ "func", "Marshal", "(", "v", "Marshaler", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "v", ".", "MarshalEasyJSON", "(", "&", "w", ")", "\n", "return", "w", ".", "BuildBytes", "(", ")", ...
// Marshal returns data as a single byte slice. Method is suboptimal as the data is likely to be copied // from a chain of smaller chunks.
[ "Marshal", "returns", "data", "as", "a", "single", "byte", "slice", ".", "Method", "is", "suboptimal", "as", "the", "data", "is", "likely", "to", "be", "copied", "from", "a", "chain", "of", "smaller", "chunks", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L31-L35
30,688
mailru/easyjson
helpers.go
MarshalToWriter
func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error) { jw := jwriter.Writer{} v.MarshalEasyJSON(&jw) return jw.DumpTo(w) }
go
func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error) { jw := jwriter.Writer{} v.MarshalEasyJSON(&jw) return jw.DumpTo(w) }
[ "func", "MarshalToWriter", "(", "v", "Marshaler", ",", "w", "io", ".", "Writer", ")", "(", "written", "int", ",", "err", "error", ")", "{", "jw", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "v", ".", "MarshalEasyJSON", "(", "&", "jw", ")", "\n"...
// MarshalToWriter marshals the data to an io.Writer.
[ "MarshalToWriter", "marshals", "the", "data", "to", "an", "io", ".", "Writer", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L38-L42
30,689
mailru/easyjson
helpers.go
Unmarshal
func Unmarshal(data []byte, v Unmarshaler) error { l := jlexer.Lexer{Data: data} v.UnmarshalEasyJSON(&l) return l.Error() }
go
func Unmarshal(data []byte, v Unmarshaler) error { l := jlexer.Lexer{Data: data} v.UnmarshalEasyJSON(&l) return l.Error() }
[ "func", "Unmarshal", "(", "data", "[", "]", "byte", ",", "v", "Unmarshaler", ")", "error", "{", "l", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "v", ".", "UnmarshalEasyJSON", "(", "&", "l", ")", "\n", "return", "l", ".", "...
// Unmarshal decodes the JSON in data into the object.
[ "Unmarshal", "decodes", "the", "JSON", "in", "data", "into", "the", "object", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L63-L67
30,690
mailru/easyjson
helpers.go
UnmarshalFromReader
func UnmarshalFromReader(r io.Reader, v Unmarshaler) error { data, err := ioutil.ReadAll(r) if err != nil { return err } l := jlexer.Lexer{Data: data} v.UnmarshalEasyJSON(&l) return l.Error() }
go
func UnmarshalFromReader(r io.Reader, v Unmarshaler) error { data, err := ioutil.ReadAll(r) if err != nil { return err } l := jlexer.Lexer{Data: data} v.UnmarshalEasyJSON(&l) return l.Error() }
[ "func", "UnmarshalFromReader", "(", "r", "io", ".", "Reader", ",", "v", "Unmarshaler", ")", "error", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "l",...
// UnmarshalFromReader reads all the data in the reader and decodes as JSON into the object.
[ "UnmarshalFromReader", "reads", "all", "the", "data", "in", "the", "reader", "and", "decodes", "as", "JSON", "into", "the", "object", "." ]
1ea4449da9834f4d333f1cc461c374aea217d249
https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L70-L78
30,691
fogleman/gg
gradient.go
Less
func (s stops) Less(i, j int) bool { return s[i].pos < s[j].pos }
go
func (s stops) Less(i, j int) bool { return s[i].pos < s[j].pos }
[ "func", "(", "s", "stops", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", ".", "pos", "<", "s", "[", "j", "]", ".", "pos", "\n", "}" ]
// Less satisfies the Sort interface.
[ "Less", "satisfies", "the", "Sort", "interface", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/gradient.go#L22-L24
30,692
fogleman/gg
gradient.go
Swap
func (s stops) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s stops) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "stops", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap satisfies the Sort interface.
[ "Swap", "satisfies", "the", "Sort", "interface", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/gradient.go#L27-L29
30,693
fogleman/gg
util.go
LoadFontFace
func LoadFontFace(path string, points float64) (font.Face, error) { fontBytes, err := ioutil.ReadFile(path) if err != nil { return nil, err } f, err := truetype.Parse(fontBytes) if err != nil { return nil, err } face := truetype.NewFace(f, &truetype.Options{ Size: points, // Hinting: font.HintingFull, }...
go
func LoadFontFace(path string, points float64) (font.Face, error) { fontBytes, err := ioutil.ReadFile(path) if err != nil { return nil, err } f, err := truetype.Parse(fontBytes) if err != nil { return nil, err } face := truetype.NewFace(f, &truetype.Options{ Size: points, // Hinting: font.HintingFull, }...
[ "func", "LoadFontFace", "(", "path", "string", ",", "points", "float64", ")", "(", "font", ".", "Face", ",", "error", ")", "{", "fontBytes", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return",...
// LoadFontFace is a helper function to load the specified font file with // the specified point size. Note that the returned `font.Face` objects // are not thread safe and cannot be used in parallel across goroutines. // You can usually just use the Context.LoadFontFace function instead of // this package-level functi...
[ "LoadFontFace", "is", "a", "helper", "function", "to", "load", "the", "specified", "font", "file", "with", "the", "specified", "point", "size", ".", "Note", "that", "the", "returned", "font", ".", "Face", "objects", "are", "not", "thread", "safe", "and", "...
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/util.go#L132-L146
30,694
fogleman/gg
context.go
NewContext
func NewContext(width, height int) *Context { return NewContextForRGBA(image.NewRGBA(image.Rect(0, 0, width, height))) }
go
func NewContext(width, height int) *Context { return NewContextForRGBA(image.NewRGBA(image.Rect(0, 0, width, height))) }
[ "func", "NewContext", "(", "width", ",", "height", "int", ")", "*", "Context", "{", "return", "NewContextForRGBA", "(", "image", ".", "NewRGBA", "(", "image", ".", "Rect", "(", "0", ",", "0", ",", "width", ",", "height", ")", ")", ")", "\n", "}" ]
// NewContext creates a new image.RGBA with the specified width and height // and prepares a context for rendering onto that image.
[ "NewContext", "creates", "a", "new", "image", ".", "RGBA", "with", "the", "specified", "width", "and", "height", "and", "prepares", "a", "context", "for", "rendering", "onto", "that", "image", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L83-L85
30,695
fogleman/gg
context.go
NewContextForRGBA
func NewContextForRGBA(im *image.RGBA) *Context { w := im.Bounds().Size().X h := im.Bounds().Size().Y return &Context{ width: w, height: h, rasterizer: raster.NewRasterizer(w, h), im: im, color: color.Transparent, fillPattern: defaultFillStyle, strokePattern: defa...
go
func NewContextForRGBA(im *image.RGBA) *Context { w := im.Bounds().Size().X h := im.Bounds().Size().Y return &Context{ width: w, height: h, rasterizer: raster.NewRasterizer(w, h), im: im, color: color.Transparent, fillPattern: defaultFillStyle, strokePattern: defa...
[ "func", "NewContextForRGBA", "(", "im", "*", "image", ".", "RGBA", ")", "*", "Context", "{", "w", ":=", "im", ".", "Bounds", "(", ")", ".", "Size", "(", ")", ".", "X", "\n", "h", ":=", "im", ".", "Bounds", "(", ")", ".", "Size", "(", ")", "."...
// NewContextForRGBA prepares a context for rendering onto the specified image. // No copy is made.
[ "NewContextForRGBA", "prepares", "a", "context", "for", "rendering", "onto", "the", "specified", "image", ".", "No", "copy", "is", "made", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L95-L112
30,696
fogleman/gg
context.go
GetCurrentPoint
func (dc *Context) GetCurrentPoint() (Point, bool) { if dc.hasCurrent { return dc.current, true } return Point{}, false }
go
func (dc *Context) GetCurrentPoint() (Point, bool) { if dc.hasCurrent { return dc.current, true } return Point{}, false }
[ "func", "(", "dc", "*", "Context", ")", "GetCurrentPoint", "(", ")", "(", "Point", ",", "bool", ")", "{", "if", "dc", ".", "hasCurrent", "{", "return", "dc", ".", "current", ",", "true", "\n", "}", "\n", "return", "Point", "{", "}", ",", "false", ...
// GetCurrentPoint will return the current point and if there is a current point. // The point will have been transformed by the context's transformation matrix.
[ "GetCurrentPoint", "will", "return", "the", "current", "point", "and", "if", "there", "is", "a", "current", "point", ".", "The", "point", "will", "have", "been", "transformed", "by", "the", "context", "s", "transformation", "matrix", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L116-L121
30,697
fogleman/gg
context.go
SavePNG
func (dc *Context) SavePNG(path string) error { return SavePNG(path, dc.im) }
go
func (dc *Context) SavePNG(path string) error { return SavePNG(path, dc.im) }
[ "func", "(", "dc", "*", "Context", ")", "SavePNG", "(", "path", "string", ")", "error", "{", "return", "SavePNG", "(", "path", ",", "dc", ".", "im", ")", "\n", "}" ]
// SavePNG encodes the image as a PNG and writes it to disk.
[ "SavePNG", "encodes", "the", "image", "as", "a", "PNG", "and", "writes", "it", "to", "disk", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L139-L141
30,698
fogleman/gg
context.go
SaveJPG
func (dc *Context) SaveJPG(path string, quality int) error { return SaveJPG(path, dc.im, quality) }
go
func (dc *Context) SaveJPG(path string, quality int) error { return SaveJPG(path, dc.im, quality) }
[ "func", "(", "dc", "*", "Context", ")", "SaveJPG", "(", "path", "string", ",", "quality", "int", ")", "error", "{", "return", "SaveJPG", "(", "path", ",", "dc", ".", "im", ",", "quality", ")", "\n", "}" ]
// SaveJPG encodes the image as a JPG and writes it to disk.
[ "SaveJPG", "encodes", "the", "image", "as", "a", "JPG", "and", "writes", "it", "to", "disk", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L144-L146
30,699
fogleman/gg
context.go
EncodePNG
func (dc *Context) EncodePNG(w io.Writer) error { return png.Encode(w, dc.im) }
go
func (dc *Context) EncodePNG(w io.Writer) error { return png.Encode(w, dc.im) }
[ "func", "(", "dc", "*", "Context", ")", "EncodePNG", "(", "w", "io", ".", "Writer", ")", "error", "{", "return", "png", ".", "Encode", "(", "w", ",", "dc", ".", "im", ")", "\n", "}" ]
// EncodePNG encodes the image as a PNG and writes it to the provided io.Writer.
[ "EncodePNG", "encodes", "the", "image", "as", "a", "PNG", "and", "writes", "it", "to", "the", "provided", "io", ".", "Writer", "." ]
72436a171bf31757dc87fb8fa9f7485307350307
https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L149-L151