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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
132,800 | cloudfoundry/cfhttp | v2/client.go | WithIdleConnTimeout | func WithIdleConnTimeout(t time.Duration) Option {
return func(c *config) {
c.idleConnTimeout = t
}
} | go | func WithIdleConnTimeout(t time.Duration) Option {
return func(c *config) {
c.idleConnTimeout = t
}
} | [
"func",
"WithIdleConnTimeout",
"(",
"t",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"c",
"*",
"config",
")",
"{",
"c",
".",
"idleConnTimeout",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | // WithIdleConnTimeout sets the maximum amount of time a keep-alive
// connection can be idle before it closes itself.
//
// A setting of 0 means no timeout. | [
"WithIdleConnTimeout",
"sets",
"the",
"maximum",
"amount",
"of",
"time",
"a",
"keep",
"-",
"alive",
"connection",
"can",
"be",
"idle",
"before",
"it",
"closes",
"itself",
".",
"A",
"setting",
"of",
"0",
"means",
"no",
"timeout",
"."
] | 1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71 | https://github.com/cloudfoundry/cfhttp/blob/1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71/v2/client.go#L70-L74 |
132,801 | cloudfoundry/cfhttp | v2/client.go | WithTLSConfig | func WithTLSConfig(t *tls.Config) Option {
return func(c *config) {
c.tlsConfig = t
}
} | go | func WithTLSConfig(t *tls.Config) Option {
return func(c *config) {
c.tlsConfig = t
}
} | [
"func",
"WithTLSConfig",
"(",
"t",
"*",
"tls",
".",
"Config",
")",
"Option",
"{",
"return",
"func",
"(",
"c",
"*",
"config",
")",
"{",
"c",
".",
"tlsConfig",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | // WithTLSConfig sets the TLS configuration on the HTTP client. | [
"WithTLSConfig",
"sets",
"the",
"TLS",
"configuration",
"on",
"the",
"HTTP",
"client",
"."
] | 1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71 | https://github.com/cloudfoundry/cfhttp/blob/1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71/v2/client.go#L96-L100 |
132,802 | cloudfoundry/cfhttp | v2/client.go | NewClient | func NewClient(options ...Option) *http.Client {
cfg := config{
dialTimeout: 5 * time.Second,
tcpKeepAliveTimeout: 0,
idleConnTimeout: 90 * time.Second,
}
for _, v := range options {
v(&cfg)
}
return &http.Client{
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: cfg.di... | go | func NewClient(options ...Option) *http.Client {
cfg := config{
dialTimeout: 5 * time.Second,
tcpKeepAliveTimeout: 0,
idleConnTimeout: 90 * time.Second,
}
for _, v := range options {
v(&cfg)
}
return &http.Client{
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: cfg.di... | [
"func",
"NewClient",
"(",
"options",
"...",
"Option",
")",
"*",
"http",
".",
"Client",
"{",
"cfg",
":=",
"config",
"{",
"dialTimeout",
":",
"5",
"*",
"time",
".",
"Second",
",",
"tcpKeepAliveTimeout",
":",
"0",
",",
"idleConnTimeout",
":",
"90",
"*",
"... | // NewClient builds a HTTP client with suitable defaults.
// The Options can optionally set configuration options on the
// HTTP client, transport, or net dialer. Options are applied
// in the order that they are passed in, so it is possible for
// later Options previous ones. | [
"NewClient",
"builds",
"a",
"HTTP",
"client",
"with",
"suitable",
"defaults",
".",
"The",
"Options",
"can",
"optionally",
"set",
"configuration",
"options",
"on",
"the",
"HTTP",
"client",
"transport",
"or",
"net",
"dialer",
".",
"Options",
"are",
"applied",
"i... | 1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71 | https://github.com/cloudfoundry/cfhttp/blob/1f526aa7822e788b7e8b9dd097b0cf8c5b2fdb71/v2/client.go#L107-L129 |
132,803 | jzelinskie/geddit | login_session.go | NewLoginSession | func NewLoginSession(username, password, useragent string) (*LoginSession, error) {
session := &LoginSession{
username: username,
password: password,
useragent: useragent,
Session: Session{useragent},
}
loginURL := fmt.Sprintf("https://www.reddit.com/api/login/%s", username)
postValues := url.Values{
... | go | func NewLoginSession(username, password, useragent string) (*LoginSession, error) {
session := &LoginSession{
username: username,
password: password,
useragent: useragent,
Session: Session{useragent},
}
loginURL := fmt.Sprintf("https://www.reddit.com/api/login/%s", username)
postValues := url.Values{
... | [
"func",
"NewLoginSession",
"(",
"username",
",",
"password",
",",
"useragent",
"string",
")",
"(",
"*",
"LoginSession",
",",
"error",
")",
"{",
"session",
":=",
"&",
"LoginSession",
"{",
"username",
":",
"username",
",",
"password",
":",
"password",
",",
"... | // NewLoginSession creates a new session for those who want to log into a
// reddit account. | [
"NewLoginSession",
"creates",
"a",
"new",
"session",
"for",
"those",
"who",
"want",
"to",
"log",
"into",
"a",
"reddit",
"account",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L33-L98 |
132,804 | jzelinskie/geddit | login_session.go | Clear | func (s LoginSession) Clear() error {
req := &request{
url: "https://www.reddit.com/api/clear_sessions",
values: &url.Values{
"curpass": {s.password},
"uh": {s.modhash},
},
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return err
}
if !strings.Contains(body.String(... | go | func (s LoginSession) Clear() error {
req := &request{
url: "https://www.reddit.com/api/clear_sessions",
values: &url.Values{
"curpass": {s.password},
"uh": {s.modhash},
},
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return err
}
if !strings.Contains(body.String(... | [
"func",
"(",
"s",
"LoginSession",
")",
"Clear",
"(",
")",
"error",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"\"",
"\"",
",",
"values",
":",
"&",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"s",
".",
"password",
"}",
",",
"\"",
... | // Clear clears all session cookies and updates the current session with a new one. | [
"Clear",
"clears",
"all",
"session",
"cookies",
"and",
"updates",
"the",
"current",
"session",
"with",
"a",
"new",
"one",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L101-L119 |
132,805 | jzelinskie/geddit | login_session.go | Frontpage | func (s LoginSession) Frontpage(sort PopularitySort, params ListingOptions) ([]*Submission, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
var redditUrl string
if sort == DefaultPopularity {
redditUrl = fmt.Sprintf("https://www.reddit.com/.json?%s", v.Encode())
} else {
redditUr... | go | func (s LoginSession) Frontpage(sort PopularitySort, params ListingOptions) ([]*Submission, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
var redditUrl string
if sort == DefaultPopularity {
redditUrl = fmt.Sprintf("https://www.reddit.com/.json?%s", v.Encode())
} else {
redditUr... | [
"func",
"(",
"s",
"LoginSession",
")",
"Frontpage",
"(",
"sort",
"PopularitySort",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"query",
".",
"Values",
"(",
"params",
")",
"\n",
... | // Frontpage returns the submissions on the logged-in user's personal frontpage. | [
"Frontpage",
"returns",
"the",
"submissions",
"on",
"the",
"logged",
"-",
"in",
"user",
"s",
"personal",
"frontpage",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L122-L165 |
132,806 | jzelinskie/geddit | login_session.go | Me | func (s LoginSession) Me() (*Redditor, error) {
req := &request{
url: "https://www.reddit.com/api/me.json",
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
type Response struct {
Data Redditor
}
r := &Response{}
err = json.NewDeco... | go | func (s LoginSession) Me() (*Redditor, error) {
req := &request{
url: "https://www.reddit.com/api/me.json",
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
type Response struct {
Data Redditor
}
r := &Response{}
err = json.NewDeco... | [
"func",
"(",
"s",
"LoginSession",
")",
"Me",
"(",
")",
"(",
"*",
"Redditor",
",",
"error",
")",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"\"",
"\"",
",",
"cookie",
":",
"s",
".",
"cookie",
",",
"useragent",
":",
"s",
".",
"useragent",
... | // Me returns an up-to-date redditor object of the logged-in user. | [
"Me",
"returns",
"an",
"up",
"-",
"to",
"-",
"date",
"redditor",
"object",
"of",
"the",
"logged",
"-",
"in",
"user",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L168-L189 |
132,807 | jzelinskie/geddit | login_session.go | Vote | func (s LoginSession) Vote(v Voter, vote Vote) error {
req := &request{
url: "https://www.reddit.com/api/vote",
values: &url.Values{
"id": {v.voteID()},
"dir": {string(vote)},
"uh": {s.modhash},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
r... | go | func (s LoginSession) Vote(v Voter, vote Vote) error {
req := &request{
url: "https://www.reddit.com/api/vote",
values: &url.Values{
"id": {v.voteID()},
"dir": {string(vote)},
"uh": {s.modhash},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
r... | [
"func",
"(",
"s",
"LoginSession",
")",
"Vote",
"(",
"v",
"Voter",
",",
"vote",
"Vote",
")",
"error",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"\"",
"\"",
",",
"values",
":",
"&",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"v",
... | // Vote either votes or rescinds a vote for a Submission or Comment. | [
"Vote",
"either",
"votes",
"or",
"rescinds",
"a",
"vote",
"for",
"a",
"Submission",
"or",
"Comment",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L231-L250 |
132,808 | jzelinskie/geddit | login_session.go | Reply | func (s LoginSession) Reply(r Replier, comment string) error {
req := &request{
url: "https://www.reddit.com/api/comment",
values: &url.Values{
"thing_id": {r.replyID()},
"text": {comment},
"uh": {s.modhash},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse... | go | func (s LoginSession) Reply(r Replier, comment string) error {
req := &request{
url: "https://www.reddit.com/api/comment",
values: &url.Values{
"thing_id": {r.replyID()},
"text": {comment},
"uh": {s.modhash},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse... | [
"func",
"(",
"s",
"LoginSession",
")",
"Reply",
"(",
"r",
"Replier",
",",
"comment",
"string",
")",
"error",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"\"",
"\"",
",",
"values",
":",
"&",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
... | // Reply posts a comment as a response to a Submission or Comment. | [
"Reply",
"posts",
"a",
"comment",
"as",
"a",
"response",
"to",
"a",
"Submission",
"or",
"Comment",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L253-L275 |
132,809 | jzelinskie/geddit | login_session.go | Delete | func (s LoginSession) Delete(d Deleter) error {
req := &request{
url: "https://www.reddit.com/api/del",
values: &url.Values{
"id": {d.deleteID()},
"uh": {s.modhash},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return err
}
if !strings.Contai... | go | func (s LoginSession) Delete(d Deleter) error {
req := &request{
url: "https://www.reddit.com/api/del",
values: &url.Values{
"id": {d.deleteID()},
"uh": {s.modhash},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return err
}
if !strings.Contai... | [
"func",
"(",
"s",
"LoginSession",
")",
"Delete",
"(",
"d",
"Deleter",
")",
"error",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"\"",
"\"",
",",
"values",
":",
"&",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"d",
".",
"deleteID",
"... | // Delete deletes a Submission or Comment. | [
"Delete",
"deletes",
"a",
"Submission",
"or",
"Comment",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L278-L299 |
132,810 | jzelinskie/geddit | login_session.go | NeedsCaptcha | func (s LoginSession) NeedsCaptcha() (bool, error) {
req := &request{
url: "https://www.reddit.com/api/needs_captcha.json",
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return false, err
}
need, err := strconv.ParseBool(body.String())
if err != n... | go | func (s LoginSession) NeedsCaptcha() (bool, error) {
req := &request{
url: "https://www.reddit.com/api/needs_captcha.json",
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return false, err
}
need, err := strconv.ParseBool(body.String())
if err != n... | [
"func",
"(",
"s",
"LoginSession",
")",
"NeedsCaptcha",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"\"",
"\"",
",",
"cookie",
":",
"s",
".",
"cookie",
",",
"useragent",
":",
"s",
".",
"useragent",
... | // NeedsCaptcha returns true if captcha is required, false if it isn't | [
"NeedsCaptcha",
"returns",
"true",
"if",
"captcha",
"is",
"required",
"false",
"if",
"it",
"isn",
"t"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L302-L322 |
132,811 | jzelinskie/geddit | login_session.go | NewCaptchaIden | func (s LoginSession) NewCaptchaIden() (string, error) {
req := &request{
url: "https://www.reddit.com/api/new_captcha",
values: &url.Values{
"api_type": {"json"},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return "", err
}
// Get the CAPTCHA i... | go | func (s LoginSession) NewCaptchaIden() (string, error) {
req := &request{
url: "https://www.reddit.com/api/new_captcha",
values: &url.Values{
"api_type": {"json"},
},
cookie: s.cookie,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return "", err
}
// Get the CAPTCHA i... | [
"func",
"(",
"s",
"LoginSession",
")",
"NewCaptchaIden",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"\"",
"\"",
",",
"values",
":",
"&",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"\"",
... | // NewCaptchaIden gets a new captcha iden from reddit | [
"NewCaptchaIden",
"gets",
"a",
"new",
"captcha",
"iden",
"from",
"reddit"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L325-L356 |
132,812 | jzelinskie/geddit | login_session.go | Listing | func (s LoginSession) Listing(username, listing string, sort PopularitySort, after string) ([]*Submission, error) {
values := &url.Values{}
if sort != "" {
values.Set("sort", string(sort))
}
if after != "" {
values.Set("after", after)
}
url := fmt.Sprintf("https://www.reddit.com/user/%s/%s.json?%s", username,... | go | func (s LoginSession) Listing(username, listing string, sort PopularitySort, after string) ([]*Submission, error) {
values := &url.Values{}
if sort != "" {
values.Set("sort", string(sort))
}
if after != "" {
values.Set("after", after)
}
url := fmt.Sprintf("https://www.reddit.com/user/%s/%s.json?%s", username,... | [
"func",
"(",
"s",
"LoginSession",
")",
"Listing",
"(",
"username",
",",
"listing",
"string",
",",
"sort",
"PopularitySort",
",",
"after",
"string",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"values",
":=",
"&",
"url",
".",
"Values"... | // Listing returns a listing for an user | [
"Listing",
"returns",
"a",
"listing",
"for",
"an",
"user"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L359-L399 |
132,813 | jzelinskie/geddit | login_session.go | MyOverview | func (s LoginSession) MyOverview(sort PopularitySort, after string) ([]*Submission, error) {
return s.Listing(s.username, "overview", sort, after)
} | go | func (s LoginSession) MyOverview(sort PopularitySort, after string) ([]*Submission, error) {
return s.Listing(s.username, "overview", sort, after)
} | [
"func",
"(",
"s",
"LoginSession",
")",
"MyOverview",
"(",
"sort",
"PopularitySort",
",",
"after",
"string",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"return",
"s",
".",
"Listing",
"(",
"s",
".",
"username",
",",
"\"",
"\"",
",",... | // Fetch the Overview listing for the logged-in user | [
"Fetch",
"the",
"Overview",
"listing",
"for",
"the",
"logged",
"-",
"in",
"user"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/login_session.go#L402-L404 |
132,814 | jzelinskie/geddit | session.go | DefaultFrontpage | func (s Session) DefaultFrontpage(sort PopularitySort, params ListingOptions) ([]*Submission, error) {
return s.SubredditSubmissions("", sort, params)
} | go | func (s Session) DefaultFrontpage(sort PopularitySort, params ListingOptions) ([]*Submission, error) {
return s.SubredditSubmissions("", sort, params)
} | [
"func",
"(",
"s",
"Session",
")",
"DefaultFrontpage",
"(",
"sort",
"PopularitySort",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"return",
"s",
".",
"SubredditSubmissions",
"(",
"\"",
"\"",
",",
"sort",
... | // DefaultFrontpage returns the submissions on the default reddit frontpage. | [
"DefaultFrontpage",
"returns",
"the",
"submissions",
"on",
"the",
"default",
"reddit",
"frontpage",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L30-L32 |
132,815 | jzelinskie/geddit | session.go | SubredditSubmissions | func (s Session) SubredditSubmissions(subreddit string, sort PopularitySort, params ListingOptions) ([]*Submission, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
baseUrl := "https://www.reddit.com"
// If subbreddit given, add to URL
if subreddit != "" {
baseUrl += "/r/" + subredd... | go | func (s Session) SubredditSubmissions(subreddit string, sort PopularitySort, params ListingOptions) ([]*Submission, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
baseUrl := "https://www.reddit.com"
// If subbreddit given, add to URL
if subreddit != "" {
baseUrl += "/r/" + subredd... | [
"func",
"(",
"s",
"Session",
")",
"SubredditSubmissions",
"(",
"subreddit",
"string",
",",
"sort",
"PopularitySort",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"query",
".",
"Val... | // SubredditSubmissions returns the submissions on the given subreddit. | [
"SubredditSubmissions",
"returns",
"the",
"submissions",
"on",
"the",
"given",
"subreddit",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L35-L79 |
132,816 | jzelinskie/geddit | session.go | SubmissionsComments | func (s Session) SubmissionsComments(submissionID string) ([]*Comment, error) {
redditURL := "https://www.reddit.com"
redditURL += "/comments/" + submissionID
redditURL += ".json"
req := request{
url: redditURL,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err... | go | func (s Session) SubmissionsComments(submissionID string) ([]*Comment, error) {
redditURL := "https://www.reddit.com"
redditURL += "/comments/" + submissionID
redditURL += ".json"
req := request{
url: redditURL,
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err... | [
"func",
"(",
"s",
"Session",
")",
"SubmissionsComments",
"(",
"submissionID",
"string",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"error",
")",
"{",
"redditURL",
":=",
"\"",
"\"",
"\n",
"redditURL",
"+=",
"\"",
"\"",
"+",
"submissionID",
"\n",
"redditURL"... | // SubmissionComments returns the comments on a submission given it's ID. | [
"SubmissionComments",
"returns",
"the",
"comments",
"on",
"a",
"submission",
"given",
"it",
"s",
"ID",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L82-L105 |
132,817 | jzelinskie/geddit | session.go | AboutRedditor | func (s Session) AboutRedditor(username string) (*Redditor, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/user/%s/about.json", username),
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
type Response struct {
Data Redditor
}
r := new... | go | func (s Session) AboutRedditor(username string) (*Redditor, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/user/%s/about.json", username),
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
type Response struct {
Data Redditor
}
r := new... | [
"func",
"(",
"s",
"Session",
")",
"AboutRedditor",
"(",
"username",
"string",
")",
"(",
"*",
"Redditor",
",",
"error",
")",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"username",
")",
",",
"usera... | // AboutRedditor returns a Redditor for the given username. | [
"AboutRedditor",
"returns",
"a",
"Redditor",
"for",
"the",
"given",
"username",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L108-L128 |
132,818 | jzelinskie/geddit | session.go | AboutSubreddit | func (s Session) AboutSubreddit(subreddit string) (*Subreddit, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/r/%s/about.json", subreddit),
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
type Response struct {
Data Subreddit
}
r := ... | go | func (s Session) AboutSubreddit(subreddit string) (*Subreddit, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/r/%s/about.json", subreddit),
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
type Response struct {
Data Subreddit
}
r := ... | [
"func",
"(",
"s",
"Session",
")",
"AboutSubreddit",
"(",
"subreddit",
"string",
")",
"(",
"*",
"Subreddit",
",",
"error",
")",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"subreddit",
")",
",",
"u... | // AboutSubreddit returns a subreddit for the given subreddit name. | [
"AboutSubreddit",
"returns",
"a",
"subreddit",
"for",
"the",
"given",
"subreddit",
"name",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L131-L152 |
132,819 | jzelinskie/geddit | session.go | Comments | func (s Session) Comments(h *Submission) ([]*Comment, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/comments/%s/.json", h.ID),
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
r := json.NewDecoder(body)
var interf interface{}
if err = r... | go | func (s Session) Comments(h *Submission) ([]*Comment, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/comments/%s/.json", h.ID),
useragent: s.useragent,
}
body, err := req.getResponse()
if err != nil {
return nil, err
}
r := json.NewDecoder(body)
var interf interface{}
if err = r... | [
"func",
"(",
"s",
"Session",
")",
"Comments",
"(",
"h",
"*",
"Submission",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"error",
")",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
".",
"ID",
... | // Comments returns the comments for a given Submission. | [
"Comments",
"returns",
"the",
"comments",
"for",
"a",
"given",
"Submission",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L155-L174 |
132,820 | jzelinskie/geddit | session.go | CaptchaImage | func (s Session) CaptchaImage(iden string) (image.Image, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/captcha/%s", iden),
useragent: s.useragent,
}
p, err := req.getResponse()
if err != nil {
return nil, err
}
m, err := png.Decode(p)
if err != nil {
return nil, err
}
re... | go | func (s Session) CaptchaImage(iden string) (image.Image, error) {
req := &request{
url: fmt.Sprintf("https://www.reddit.com/captcha/%s", iden),
useragent: s.useragent,
}
p, err := req.getResponse()
if err != nil {
return nil, err
}
m, err := png.Decode(p)
if err != nil {
return nil, err
}
re... | [
"func",
"(",
"s",
"Session",
")",
"CaptchaImage",
"(",
"iden",
"string",
")",
"(",
"image",
".",
"Image",
",",
"error",
")",
"{",
"req",
":=",
"&",
"request",
"{",
"url",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"iden",
")",
",",
"userag... | // CaptchaImage gets the png corresponding to the captcha iden and decodes it | [
"CaptchaImage",
"gets",
"the",
"png",
"corresponding",
"to",
"the",
"captcha",
"iden",
"and",
"decodes",
"it"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L177-L196 |
132,821 | jzelinskie/geddit | session.go | RedditorComments | func (s Session) RedditorComments(username string, params ListingOptions) ([]*Comment, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
baseUrl := "https://www.reddit.com"
// If username given, add to URL
if username != "" {
baseUrl += "/user/" + username
}
redditUrl := fmt.Sprin... | go | func (s Session) RedditorComments(username string, params ListingOptions) ([]*Comment, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
baseUrl := "https://www.reddit.com"
// If username given, add to URL
if username != "" {
baseUrl += "/user/" + username
}
redditUrl := fmt.Sprin... | [
"func",
"(",
"s",
"Session",
")",
"RedditorComments",
"(",
"username",
"string",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"query",
".",
"Values",
"(",
"params",
")",
"\n",
"if... | // RedditorComments returns a slice of Comments from a given Reddit user name. | [
"RedditorComments",
"returns",
"a",
"slice",
"of",
"Comments",
"from",
"a",
"given",
"Reddit",
"user",
"name",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/session.go#L235-L268 |
132,822 | jzelinskie/geddit | subreddit.go | String | func (s *Subreddit) String() string {
var subs string
switch s.NumSubs {
case 1:
subs = "1 subscriber"
default:
subs = fmt.Sprintf("%d subscribers", s.NumSubs)
}
return fmt.Sprintf("%s (%s)", s.Title, subs)
} | go | func (s *Subreddit) String() string {
var subs string
switch s.NumSubs {
case 1:
subs = "1 subscriber"
default:
subs = fmt.Sprintf("%d subscribers", s.NumSubs)
}
return fmt.Sprintf("%s (%s)", s.Title, subs)
} | [
"func",
"(",
"s",
"*",
"Subreddit",
")",
"String",
"(",
")",
"string",
"{",
"var",
"subs",
"string",
"\n",
"switch",
"s",
".",
"NumSubs",
"{",
"case",
"1",
":",
"subs",
"=",
"\"",
"\"",
"\n",
"default",
":",
"subs",
"=",
"fmt",
".",
"Sprintf",
"(... | // String returns the string representation of a subreddit. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"subreddit",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/subreddit.go#L27-L36 |
132,823 | jzelinskie/geddit | comment.go | makeComment | func makeComment(cmap map[string]interface{}) *Comment {
ret := new(Comment)
ret.Author, _ = cmap["author"].(string)
ret.Body, _ = cmap["body"].(string)
ret.BodyHTML, _ = cmap["body_html"].(string)
ret.Subreddit, _ = cmap["subreddit"].(string)
ret.LinkID, _ = cmap["link_id"].(string)
ret.ParentID, _ = cmap["pare... | go | func makeComment(cmap map[string]interface{}) *Comment {
ret := new(Comment)
ret.Author, _ = cmap["author"].(string)
ret.Body, _ = cmap["body"].(string)
ret.BodyHTML, _ = cmap["body_html"].(string)
ret.Subreddit, _ = cmap["subreddit"].(string)
ret.LinkID, _ = cmap["link_id"].(string)
ret.ParentID, _ = cmap["pare... | [
"func",
"makeComment",
"(",
"cmap",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"*",
"Comment",
"{",
"ret",
":=",
"new",
"(",
"Comment",
")",
"\n",
"ret",
".",
"Author",
",",
"_",
"=",
"cmap",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
... | // makeComment tries its best to fill as many fields as possible of a Comment. | [
"makeComment",
"tries",
"its",
"best",
"to",
"fill",
"as",
"many",
"fields",
"as",
"possible",
"of",
"a",
"Comment",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/comment.go#L50-L78 |
132,824 | jzelinskie/geddit | comment.go | buildComments | func (h *helper) buildComments(inf interface{}) {
switch tp := inf.(type) {
case []interface{}: //Maybe array for base comments
for _, k := range tp {
h.buildComments(k)
}
case map[string]interface{}: //Maybe comment data
if tp["body"] == nil {
for _, k := range tp {
h.buildComments(k)
}
} else ... | go | func (h *helper) buildComments(inf interface{}) {
switch tp := inf.(type) {
case []interface{}: //Maybe array for base comments
for _, k := range tp {
h.buildComments(k)
}
case map[string]interface{}: //Maybe comment data
if tp["body"] == nil {
for _, k := range tp {
h.buildComments(k)
}
} else ... | [
"func",
"(",
"h",
"*",
"helper",
")",
"buildComments",
"(",
"inf",
"interface",
"{",
"}",
")",
"{",
"switch",
"tp",
":=",
"inf",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"interface",
"{",
"}",
":",
"//Maybe array for base comments",
"for",
"_",
... | //Recursive function to find the fields we want and build the Comments
//Way too hackish for my likes | [
"Recursive",
"function",
"to",
"find",
"the",
"fields",
"we",
"want",
"and",
"build",
"the",
"Comments",
"Way",
"too",
"hackish",
"for",
"my",
"likes"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/comment.go#L87-L102 |
132,825 | jzelinskie/geddit | types.go | NewLinkSubmission | func NewLinkSubmission(sr, title, link string, replies bool, c *Captcha) *NewSubmission {
return &NewSubmission{sr, title, link, false, replies, true, true, c}
} | go | func NewLinkSubmission(sr, title, link string, replies bool, c *Captcha) *NewSubmission {
return &NewSubmission{sr, title, link, false, replies, true, true, c}
} | [
"func",
"NewLinkSubmission",
"(",
"sr",
",",
"title",
",",
"link",
"string",
",",
"replies",
"bool",
",",
"c",
"*",
"Captcha",
")",
"*",
"NewSubmission",
"{",
"return",
"&",
"NewSubmission",
"{",
"sr",
",",
"title",
",",
"link",
",",
"false",
",",
"rep... | // NewLinkSubmission returns a NewSubmission with parameters appropriate for a link submission | [
"NewLinkSubmission",
"returns",
"a",
"NewSubmission",
"with",
"parameters",
"appropriate",
"for",
"a",
"link",
"submission"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/types.go#L34-L36 |
132,826 | jzelinskie/geddit | types.go | NewTextSubmission | func NewTextSubmission(sr, title, text string, replies bool, c *Captcha) *NewSubmission {
return &NewSubmission{sr, title, text, true, replies, true, true, c}
} | go | func NewTextSubmission(sr, title, text string, replies bool, c *Captcha) *NewSubmission {
return &NewSubmission{sr, title, text, true, replies, true, true, c}
} | [
"func",
"NewTextSubmission",
"(",
"sr",
",",
"title",
",",
"text",
"string",
",",
"replies",
"bool",
",",
"c",
"*",
"Captcha",
")",
"*",
"NewSubmission",
"{",
"return",
"&",
"NewSubmission",
"{",
"sr",
",",
"title",
",",
"text",
",",
"true",
",",
"repl... | // NewTextSubmission returns a NewSubmission with parameters appropriate for a text submission | [
"NewTextSubmission",
"returns",
"a",
"NewSubmission",
"with",
"parameters",
"appropriate",
"for",
"a",
"text",
"submission"
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/types.go#L39-L41 |
132,827 | jzelinskie/geddit | redditor.go | String | func (r *Redditor) String() string {
return fmt.Sprintf("%s (%d-%d)", r.Name, r.LinkKarma, r.CommentKarma)
} | go | func (r *Redditor) String() string {
return fmt.Sprintf("%s (%d-%d)", r.Name, r.LinkKarma, r.CommentKarma)
} | [
"func",
"(",
"r",
"*",
"Redditor",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"Name",
",",
"r",
".",
"LinkKarma",
",",
"r",
".",
"CommentKarma",
")",
"\n",
"}"
] | // String returns the string representation of a reddit user. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"reddit",
"user",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/redditor.go#L64-L66 |
132,828 | jzelinskie/geddit | oauth_session.go | RoundTrip | func (t *transport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
req.Header.Set("User-Agent", t.useragent)
return t.RoundTripper.RoundTrip(req)
} | go | func (t *transport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
req.Header.Set("User-Agent", t.useragent)
return t.RoundTripper.RoundTrip(req)
} | [
"func",
"(",
"t",
"*",
"transport",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"t",
".",
"use... | // Any request headers can be modified here. | [
"Any",
"request",
"headers",
"can",
"be",
"modified",
"here",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L31-L34 |
132,829 | jzelinskie/geddit | oauth_session.go | NewOAuthSession | func NewOAuthSession(clientID, clientSecret, useragent, redirectURL string) (*OAuthSession, error) {
o := &OAuthSession{}
if len(useragent) > 0 {
o.UserAgent = useragent
} else {
o.UserAgent = "Geddit Reddit Bot https://github.com/jzelinskie/geddit"
}
// Set OAuth config
o.OAuthConfig = &oauth2.Config{
Cl... | go | func NewOAuthSession(clientID, clientSecret, useragent, redirectURL string) (*OAuthSession, error) {
o := &OAuthSession{}
if len(useragent) > 0 {
o.UserAgent = useragent
} else {
o.UserAgent = "Geddit Reddit Bot https://github.com/jzelinskie/geddit"
}
// Set OAuth config
o.OAuthConfig = &oauth2.Config{
Cl... | [
"func",
"NewOAuthSession",
"(",
"clientID",
",",
"clientSecret",
",",
"useragent",
",",
"redirectURL",
"string",
")",
"(",
"*",
"OAuthSession",
",",
"error",
")",
"{",
"o",
":=",
"&",
"OAuthSession",
"{",
"}",
"\n\n",
"if",
"len",
"(",
"useragent",
")",
... | // NewOAuthSession creates a new session for those who want to log into a
// reddit account via OAuth. | [
"NewOAuthSession",
"creates",
"a",
"new",
"session",
"for",
"those",
"who",
"want",
"to",
"log",
"into",
"a",
"reddit",
"account",
"via",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L51-L76 |
132,830 | jzelinskie/geddit | oauth_session.go | Throttle | func (o *OAuthSession) Throttle(interval time.Duration) {
if interval == 0 {
o.throttle = nil
return
}
o.throttle = rate.New(1, interval)
} | go | func (o *OAuthSession) Throttle(interval time.Duration) {
if interval == 0 {
o.throttle = nil
return
}
o.throttle = rate.New(1, interval)
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Throttle",
"(",
"interval",
"time",
".",
"Duration",
")",
"{",
"if",
"interval",
"==",
"0",
"{",
"o",
".",
"throttle",
"=",
"nil",
"\n",
"return",
"\n",
"}",
"\n",
"o",
".",
"throttle",
"=",
"rate",
".",... | // Throttle sets the interval of each HTTP request.
// Disable by setting interval to 0. Disabled by default.
// Throttling is applied to invidual OAuthSession types. | [
"Throttle",
"sets",
"the",
"interval",
"of",
"each",
"HTTP",
"request",
".",
"Disable",
"by",
"setting",
"interval",
"to",
"0",
".",
"Disabled",
"by",
"default",
".",
"Throttling",
"is",
"applied",
"to",
"invidual",
"OAuthSession",
"types",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L81-L87 |
132,831 | jzelinskie/geddit | oauth_session.go | LoginAuth | func (o *OAuthSession) LoginAuth(username, password string) error {
// Fetch OAuth token.
t, err := o.OAuthConfig.PasswordCredentialsToken(o.ctx, username, password)
if err != nil {
return err
}
if !t.Valid() {
msg := "Invalid OAuth token"
if t != nil {
if extra := t.Extra("error"); extra != nil {
msg... | go | func (o *OAuthSession) LoginAuth(username, password string) error {
// Fetch OAuth token.
t, err := o.OAuthConfig.PasswordCredentialsToken(o.ctx, username, password)
if err != nil {
return err
}
if !t.Valid() {
msg := "Invalid OAuth token"
if t != nil {
if extra := t.Extra("error"); extra != nil {
msg... | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"LoginAuth",
"(",
"username",
",",
"password",
"string",
")",
"error",
"{",
"// Fetch OAuth token.",
"t",
",",
"err",
":=",
"o",
".",
"OAuthConfig",
".",
"PasswordCredentialsToken",
"(",
"o",
".",
"ctx",
",",
"us... | // LoginAuth creates the required HTTP client with a new token. | [
"LoginAuth",
"creates",
"the",
"required",
"HTTP",
"client",
"with",
"a",
"new",
"token",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L90-L107 |
132,832 | jzelinskie/geddit | oauth_session.go | AuthCodeURL | func (o *OAuthSession) AuthCodeURL(state string, scopes []string) string {
o.OAuthConfig.Scopes = scopes
return o.OAuthConfig.AuthCodeURL(state, oauth2.AccessTypeOnline)
} | go | func (o *OAuthSession) AuthCodeURL(state string, scopes []string) string {
o.OAuthConfig.Scopes = scopes
return o.OAuthConfig.AuthCodeURL(state, oauth2.AccessTypeOnline)
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"AuthCodeURL",
"(",
"state",
"string",
",",
"scopes",
"[",
"]",
"string",
")",
"string",
"{",
"o",
".",
"OAuthConfig",
".",
"Scopes",
"=",
"scopes",
"\n",
"return",
"o",
".",
"OAuthConfig",
".",
"AuthCodeURL",
... | // AuthCodeURL creates and returns an auth URL which contains an auth code. | [
"AuthCodeURL",
"creates",
"and",
"returns",
"an",
"auth",
"URL",
"which",
"contains",
"an",
"auth",
"code",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L110-L113 |
132,833 | jzelinskie/geddit | oauth_session.go | CodeAuth | func (o *OAuthSession) CodeAuth(code string) error {
t, err := o.OAuthConfig.Exchange(o.ctx, code)
if err != nil {
return err
}
o.Client = o.OAuthConfig.Client(o.ctx, t)
return nil
} | go | func (o *OAuthSession) CodeAuth(code string) error {
t, err := o.OAuthConfig.Exchange(o.ctx, code)
if err != nil {
return err
}
o.Client = o.OAuthConfig.Client(o.ctx, t)
return nil
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"CodeAuth",
"(",
"code",
"string",
")",
"error",
"{",
"t",
",",
"err",
":=",
"o",
".",
"OAuthConfig",
".",
"Exchange",
"(",
"o",
".",
"ctx",
",",
"code",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // CodeAuth creates and sets a token using an authentication code returned from AuthCodeURL. | [
"CodeAuth",
"creates",
"and",
"sets",
"a",
"token",
"using",
"an",
"authentication",
"code",
"returned",
"from",
"AuthCodeURL",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L116-L123 |
132,834 | jzelinskie/geddit | oauth_session.go | NeedsCaptcha | func (o *OAuthSession) NeedsCaptcha() (bool, error) {
var b bool
err := o.getBody("https://oauth.reddit.com/api/needs_captcha", &b)
if err != nil {
return false, err
}
return b, nil
} | go | func (o *OAuthSession) NeedsCaptcha() (bool, error) {
var b bool
err := o.getBody("https://oauth.reddit.com/api/needs_captcha", &b)
if err != nil {
return false, err
}
return b, nil
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"NeedsCaptcha",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"b",
"bool",
"\n",
"err",
":=",
"o",
".",
"getBody",
"(",
"\"",
"\"",
",",
"&",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // NeedsCaptcha check whether CAPTCHAs are needed for the Submit function. | [
"NeedsCaptcha",
"check",
"whether",
"CAPTCHAs",
"are",
"needed",
"for",
"the",
"Submit",
"function",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L126-L133 |
132,835 | jzelinskie/geddit | oauth_session.go | NewCaptcha | func (o *OAuthSession) NewCaptcha() (string, error) {
// Build form for POST request.
v := url.Values{
"api_type": {"json"},
}
type captcha struct {
Json struct {
Errors [][]string
Data struct {
Iden string
}
}
}
c := &captcha{}
err := o.postBody("https://oauth.reddit.com/api/new_captcha",... | go | func (o *OAuthSession) NewCaptcha() (string, error) {
// Build form for POST request.
v := url.Values{
"api_type": {"json"},
}
type captcha struct {
Json struct {
Errors [][]string
Data struct {
Iden string
}
}
}
c := &captcha{}
err := o.postBody("https://oauth.reddit.com/api/new_captcha",... | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"NewCaptcha",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Build form for POST request.",
"v",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"\"",
"\"",
"}",
",",
"}",
"\n\n",
"type",
"capt... | // NewCaptcha returns a string used to create CAPTCHA links for users. | [
"NewCaptcha",
"returns",
"a",
"string",
"used",
"to",
"create",
"CAPTCHA",
"links",
"for",
"users",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L136-L157 |
132,836 | jzelinskie/geddit | oauth_session.go | AboutRedditor | func (o *OAuthSession) AboutRedditor(user string) (*Redditor, error) {
type redditor struct {
Data Redditor
}
r := &redditor{}
link := fmt.Sprintf("https://oauth.reddit.com/user/%s/about", user)
err := o.getBody(link, r)
if err != nil {
return nil, err
}
return &r.Data, nil
} | go | func (o *OAuthSession) AboutRedditor(user string) (*Redditor, error) {
type redditor struct {
Data Redditor
}
r := &redditor{}
link := fmt.Sprintf("https://oauth.reddit.com/user/%s/about", user)
err := o.getBody(link, r)
if err != nil {
return nil, err
}
return &r.Data, nil
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"AboutRedditor",
"(",
"user",
"string",
")",
"(",
"*",
"Redditor",
",",
"error",
")",
"{",
"type",
"redditor",
"struct",
"{",
"Data",
"Redditor",
"\n",
"}",
"\n",
"r",
":=",
"&",
"redditor",
"{",
"}",
"\n",... | // AboutRedditor returns a Redditor for the given username using OAuth. | [
"AboutRedditor",
"returns",
"a",
"Redditor",
"for",
"the",
"given",
"username",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L301-L313 |
132,837 | jzelinskie/geddit | oauth_session.go | AboutSubreddit | func (o *OAuthSession) AboutSubreddit(name string) (*Subreddit, error) {
type subreddit struct {
Data Subreddit
}
sr := &subreddit{}
link := fmt.Sprintf("https://oauth.reddit.com/r/%s/about", name)
err := o.getBody(link, sr)
if err != nil {
return nil, err
}
return &sr.Data, nil
} | go | func (o *OAuthSession) AboutSubreddit(name string) (*Subreddit, error) {
type subreddit struct {
Data Subreddit
}
sr := &subreddit{}
link := fmt.Sprintf("https://oauth.reddit.com/r/%s/about", name)
err := o.getBody(link, sr)
if err != nil {
return nil, err
}
return &sr.Data, nil
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"AboutSubreddit",
"(",
"name",
"string",
")",
"(",
"*",
"Subreddit",
",",
"error",
")",
"{",
"type",
"subreddit",
"struct",
"{",
"Data",
"Subreddit",
"\n",
"}",
"\n",
"sr",
":=",
"&",
"subreddit",
"{",
"}",
... | // AboutSubreddit returns a subreddit for the given subreddit name using OAuth. | [
"AboutSubreddit",
"returns",
"a",
"subreddit",
"for",
"the",
"given",
"subreddit",
"name",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L339-L351 |
132,838 | jzelinskie/geddit | oauth_session.go | Comments | func (o *OAuthSession) Comments(h *Submission, sort PopularitySort, params ListingOptions) ([]*Comment, error) {
p, err := query.Values(params)
if err != nil {
return nil, err
}
if sort != "" {
p.Set("sort", string(sort))
}
var c interface{}
link := fmt.Sprintf("https://oauth.reddit.com/comments/%s?%s", h.... | go | func (o *OAuthSession) Comments(h *Submission, sort PopularitySort, params ListingOptions) ([]*Comment, error) {
p, err := query.Values(params)
if err != nil {
return nil, err
}
if sort != "" {
p.Set("sort", string(sort))
}
var c interface{}
link := fmt.Sprintf("https://oauth.reddit.com/comments/%s?%s", h.... | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Comments",
"(",
"h",
"*",
"Submission",
",",
"sort",
"PopularitySort",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"query",
".",
"Val... | // Comments returns the comments for a given Submission using OAuth. | [
"Comments",
"returns",
"the",
"comments",
"for",
"a",
"given",
"Submission",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L354-L373 |
132,839 | jzelinskie/geddit | oauth_session.go | Submit | func (o *OAuthSession) Submit(ns *NewSubmission) (*Submission, error) {
// Build form for POST request.
v := url.Values{
"title": {ns.Title},
"url": {ns.Content},
"text": {ns.Content},
"sr": {ns.Subreddit},
"sendreplies": {strconv.FormatBool(ns.SendReplies)},
"resubmit": ... | go | func (o *OAuthSession) Submit(ns *NewSubmission) (*Submission, error) {
// Build form for POST request.
v := url.Values{
"title": {ns.Title},
"url": {ns.Content},
"text": {ns.Content},
"sr": {ns.Subreddit},
"sendreplies": {strconv.FormatBool(ns.SendReplies)},
"resubmit": ... | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Submit",
"(",
"ns",
"*",
"NewSubmission",
")",
"(",
"*",
"Submission",
",",
"error",
")",
"{",
"// Build form for POST request.",
"v",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"ns",
".",
"Title... | // Submit accepts a NewSubmission type and submits a new link using OAuth.
// Returns a Submission type. | [
"Submit",
"accepts",
"a",
"NewSubmission",
"type",
"and",
"submits",
"a",
"new",
"link",
"using",
"OAuth",
".",
"Returns",
"a",
"Submission",
"type",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L416-L451 |
132,840 | jzelinskie/geddit | oauth_session.go | Delete | func (o *OAuthSession) Delete(d Deleter) error {
// Build form for POST request.
v := url.Values{}
v.Add("id", d.deleteID())
return o.postBody("https://oauth.reddit.com/api/del", v, nil)
} | go | func (o *OAuthSession) Delete(d Deleter) error {
// Build form for POST request.
v := url.Values{}
v.Add("id", d.deleteID())
return o.postBody("https://oauth.reddit.com/api/del", v, nil)
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Delete",
"(",
"d",
"Deleter",
")",
"error",
"{",
"// Build form for POST request.",
"v",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"v",
".",
"Add",
"(",
"\"",
"\"",
",",
"d",
".",
"deleteID",
"(",
")",
... | // Delete deletes a link or comment using the given full name ID. | [
"Delete",
"deletes",
"a",
"link",
"or",
"comment",
"using",
"the",
"given",
"full",
"name",
"ID",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L454-L460 |
132,841 | jzelinskie/geddit | oauth_session.go | SubredditSubmissions | func (o *OAuthSession) SubredditSubmissions(subreddit string, sort PopularitySort, params ListingOptions) ([]*Submission, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
baseUrl := "https://oauth.reddit.com"
// If subbreddit given, add to URL
if subreddit != "" {
baseUrl += "/r/" +... | go | func (o *OAuthSession) SubredditSubmissions(subreddit string, sort PopularitySort, params ListingOptions) ([]*Submission, error) {
v, err := query.Values(params)
if err != nil {
return nil, err
}
baseUrl := "https://oauth.reddit.com"
// If subbreddit given, add to URL
if subreddit != "" {
baseUrl += "/r/" +... | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"SubredditSubmissions",
"(",
"subreddit",
"string",
",",
"sort",
"PopularitySort",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"query",
... | // SubredditSubmissions returns the submissions on the given subreddit using OAuth. | [
"SubredditSubmissions",
"returns",
"the",
"submissions",
"on",
"the",
"given",
"subreddit",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L463-L498 |
132,842 | jzelinskie/geddit | oauth_session.go | Frontpage | func (o *OAuthSession) Frontpage(sort PopularitySort, params ListingOptions) ([]*Submission, error) {
return o.SubredditSubmissions("", sort, params)
} | go | func (o *OAuthSession) Frontpage(sort PopularitySort, params ListingOptions) ([]*Submission, error) {
return o.SubredditSubmissions("", sort, params)
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Frontpage",
"(",
"sort",
"PopularitySort",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"return",
"o",
".",
"SubredditSubmissions",
"(",
"\"",
"\"",
",",
"sor... | // Frontpage returns the submissions on the default reddit frontpage using OAuth. | [
"Frontpage",
"returns",
"the",
"submissions",
"on",
"the",
"default",
"reddit",
"frontpage",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L501-L503 |
132,843 | jzelinskie/geddit | oauth_session.go | Vote | func (o *OAuthSession) Vote(v Voter, dir Vote) error {
// Build form for POST request.
form := url.Values{
"id": {v.voteID()},
"dir": {string(dir)},
}
var vo interface{}
err := o.postBody("https://oauth.reddit.com/api/vote", form, vo)
if err != nil {
return err
}
return nil
} | go | func (o *OAuthSession) Vote(v Voter, dir Vote) error {
// Build form for POST request.
form := url.Values{
"id": {v.voteID()},
"dir": {string(dir)},
}
var vo interface{}
err := o.postBody("https://oauth.reddit.com/api/vote", form, vo)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Vote",
"(",
"v",
"Voter",
",",
"dir",
"Vote",
")",
"error",
"{",
"// Build form for POST request.",
"form",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"v",
".",
"voteID",
"(",
")",
"}",
",",
... | // Vote either votes or rescinds a vote for a Submission or Comment using OAuth. | [
"Vote",
"either",
"votes",
"or",
"rescinds",
"a",
"vote",
"for",
"a",
"Submission",
"or",
"Comment",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L506-L519 |
132,844 | jzelinskie/geddit | oauth_session.go | Reply | func (o OAuthSession) Reply(r Replier, comment string) (*Comment, error) {
// Build form for POST request.
form := url.Values{
"api_type": {"json"},
"thing_id": {r.replyID()},
"text": {comment},
}
type response struct {
JSON struct {
Errors [][]string
Data struct {
Things []struct {
Da... | go | func (o OAuthSession) Reply(r Replier, comment string) (*Comment, error) {
// Build form for POST request.
form := url.Values{
"api_type": {"json"},
"thing_id": {r.replyID()},
"text": {comment},
}
type response struct {
JSON struct {
Errors [][]string
Data struct {
Things []struct {
Da... | [
"func",
"(",
"o",
"OAuthSession",
")",
"Reply",
"(",
"r",
"Replier",
",",
"comment",
"string",
")",
"(",
"*",
"Comment",
",",
"error",
")",
"{",
"// Build form for POST request.",
"form",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"\"",
"\"... | // Reply posts a comment as a response to a Submission or Comment using OAuth. | [
"Reply",
"posts",
"a",
"comment",
"as",
"a",
"response",
"to",
"a",
"Submission",
"or",
"Comment",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L522-L559 |
132,845 | jzelinskie/geddit | oauth_session.go | Save | func (o *OAuthSession) Save(v Voter, category string) error {
// Build form for POST request.
form := url.Values{
"id": {v.voteID()},
"category": {category},
}
var s interface{}
err := o.postBody("https://oauth.reddit.com/api/save", form, s)
if err != nil {
return err
}
return nil
} | go | func (o *OAuthSession) Save(v Voter, category string) error {
// Build form for POST request.
form := url.Values{
"id": {v.voteID()},
"category": {category},
}
var s interface{}
err := o.postBody("https://oauth.reddit.com/api/save", form, s)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Save",
"(",
"v",
"Voter",
",",
"category",
"string",
")",
"error",
"{",
"// Build form for POST request.",
"form",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"v",
".",
"voteID",
"(",
")",
"}",
... | // Save saves a link or comment using OAuth. | [
"Save",
"saves",
"a",
"link",
"or",
"comment",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L562-L575 |
132,846 | jzelinskie/geddit | oauth_session.go | Unsave | func (o *OAuthSession) Unsave(v Voter, category string) error {
// Build form for POST request.
form := url.Values{
"id": {v.voteID()},
"category": {category},
}
var u interface{}
err := o.postBody("https://oauth.reddit.com/api/unsave", form, u)
if err != nil {
return err
}
return nil
} | go | func (o *OAuthSession) Unsave(v Voter, category string) error {
// Build form for POST request.
form := url.Values{
"id": {v.voteID()},
"category": {category},
}
var u interface{}
err := o.postBody("https://oauth.reddit.com/api/unsave", form, u)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"Unsave",
"(",
"v",
"Voter",
",",
"category",
"string",
")",
"error",
"{",
"// Build form for POST request.",
"form",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"v",
".",
"voteID",
"(",
")",
"}",
... | // Unsave saves a link or comment using OAuth. | [
"Unsave",
"saves",
"a",
"link",
"or",
"comment",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L578-L591 |
132,847 | jzelinskie/geddit | oauth_session.go | SavedLinks | func (o *OAuthSession) SavedLinks(username string, params ListingOptions) ([]*Submission, error) {
return o.Listing(username, "saved", "", params)
} | go | func (o *OAuthSession) SavedLinks(username string, params ListingOptions) ([]*Submission, error) {
return o.Listing(username, "saved", "", params)
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"SavedLinks",
"(",
"username",
"string",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"return",
"o",
".",
"Listing",
"(",
"username",
",",
"\"",
"\"",
",",
... | // SavedLinks fetches links saved by given username using OAuth. | [
"SavedLinks",
"fetches",
"links",
"saved",
"by",
"given",
"username",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L594-L596 |
132,848 | jzelinskie/geddit | oauth_session.go | MySavedLinks | func (o *OAuthSession) MySavedLinks(params ListingOptions) ([]*Submission, error) {
me, err := o.Me()
if err != nil {
return nil, err
}
return o.Listing(me.Name, "saved", "", params)
} | go | func (o *OAuthSession) MySavedLinks(params ListingOptions) ([]*Submission, error) {
me, err := o.Me()
if err != nil {
return nil, err
}
return o.Listing(me.Name, "saved", "", params)
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"MySavedLinks",
"(",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Submission",
",",
"error",
")",
"{",
"me",
",",
"err",
":=",
"o",
".",
"Me",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // MySavedLinks fetches links saved by current user using OAuth. | [
"MySavedLinks",
"fetches",
"links",
"saved",
"by",
"current",
"user",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L599-L605 |
132,849 | jzelinskie/geddit | oauth_session.go | SavedComments | func (o *OAuthSession) SavedComments(user string, params ListingOptions) ([]*Comment, error) {
var s interface{}
url := fmt.Sprintf("https://oauth.reddit.com/user/%s/saved", user)
err := o.getBody(url, &s)
if err != nil {
return nil, err
}
helper := new(helper)
helper.buildComments(s)
return helper.comments,... | go | func (o *OAuthSession) SavedComments(user string, params ListingOptions) ([]*Comment, error) {
var s interface{}
url := fmt.Sprintf("https://oauth.reddit.com/user/%s/saved", user)
err := o.getBody(url, &s)
if err != nil {
return nil, err
}
helper := new(helper)
helper.buildComments(s)
return helper.comments,... | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"SavedComments",
"(",
"user",
"string",
",",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"error",
")",
"{",
"var",
"s",
"interface",
"{",
"}",
"\n",
"url",
":=",
"fmt",
".",
"Sprint... | // SavedComments fetches comments saved by given username using OAuth. | [
"SavedComments",
"fetches",
"comments",
"saved",
"by",
"given",
"username",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L608-L619 |
132,850 | jzelinskie/geddit | oauth_session.go | MySavedComments | func (o *OAuthSession) MySavedComments(params ListingOptions) ([]*Comment, error) {
me, err := o.Me()
if err != nil {
return nil, err
}
return o.SavedComments(me.Name, params)
} | go | func (o *OAuthSession) MySavedComments(params ListingOptions) ([]*Comment, error) {
me, err := o.Me()
if err != nil {
return nil, err
}
return o.SavedComments(me.Name, params)
} | [
"func",
"(",
"o",
"*",
"OAuthSession",
")",
"MySavedComments",
"(",
"params",
"ListingOptions",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"error",
")",
"{",
"me",
",",
"err",
":=",
"o",
".",
"Me",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // MySavedComments fetches comments saved by current user using OAuth. | [
"MySavedComments",
"fetches",
"comments",
"saved",
"by",
"current",
"user",
"using",
"OAuth",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/oauth_session.go#L622-L628 |
132,851 | jzelinskie/geddit | submission.go | String | func (h *Submission) String() string {
plural := ""
if h.NumComments != 1 {
plural = "s"
}
comments := fmt.Sprintf("%d comment%s", h.NumComments, plural)
return fmt.Sprintf("%d - %s (%s)", h.Score, h.Title, comments)
} | go | func (h *Submission) String() string {
plural := ""
if h.NumComments != 1 {
plural = "s"
}
comments := fmt.Sprintf("%d comment%s", h.NumComments, plural)
return fmt.Sprintf("%d - %s (%s)", h.Score, h.Title, comments)
} | [
"func",
"(",
"h",
"*",
"Submission",
")",
"String",
"(",
")",
"string",
"{",
"plural",
":=",
"\"",
"\"",
"\n",
"if",
"h",
".",
"NumComments",
"!=",
"1",
"{",
"plural",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"comments",
":=",
"fmt",
".",
"Sprintf",
"("... | // String returns the string representation of a submission. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"submission",
"."
] | a9d9445ed681c9bc2df9cce08998891b44efd806 | https://github.com/jzelinskie/geddit/blob/a9d9445ed681c9bc2df9cce08998891b44efd806/submission.go#L50-L57 |
132,852 | weaveworks/go-odp | odp/flow.go | present | func (ta TunnelAttrs) present() TunnelAttrsPresence {
// The kernel requires Ipv4Dst and Ttl to be present, so we
// always mark those as present, even if we end up wildcarding
// them.
return TunnelAttrsPresence{
TunnelId: !AllBytes(ta.TunnelId[:], 0),
Ipv4Src: !AllBytes(ta.Ipv4Src[:], 0),
Ipv4Dst: true,
... | go | func (ta TunnelAttrs) present() TunnelAttrsPresence {
// The kernel requires Ipv4Dst and Ttl to be present, so we
// always mark those as present, even if we end up wildcarding
// them.
return TunnelAttrsPresence{
TunnelId: !AllBytes(ta.TunnelId[:], 0),
Ipv4Src: !AllBytes(ta.Ipv4Src[:], 0),
Ipv4Dst: true,
... | [
"func",
"(",
"ta",
"TunnelAttrs",
")",
"present",
"(",
")",
"TunnelAttrsPresence",
"{",
"// The kernel requires Ipv4Dst and Ttl to be present, so we",
"// always mark those as present, even if we end up wildcarding",
"// them.",
"return",
"TunnelAttrsPresence",
"{",
"TunnelId",
":"... | // Extract presence information from a TunnelAttrs mask | [
"Extract",
"presence",
"information",
"from",
"a",
"TunnelAttrs",
"mask"
] | 6b0aa22550d9325eb8f43418185859e13dc0de1d | https://github.com/weaveworks/go-odp/blob/6b0aa22550d9325eb8f43418185859e13dc0de1d/odp/flow.go#L539-L554 |
132,853 | weaveworks/go-odp | odp/flow.go | mask | func (tap TunnelAttrsPresence) mask() (res TunnelAttrs) {
if tap.TunnelId {
res.TunnelId = [8]byte{
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
}
}
if tap.Ipv4Src {
res.Ipv4Src = [4]byte{0xff, 0xff, 0xff, 0xff}
}
if tap.Ipv4Dst {
res.Ipv4Dst = [4]byte{0xff, 0xff, 0xff, 0xff}
}
if tap.Tos {
... | go | func (tap TunnelAttrsPresence) mask() (res TunnelAttrs) {
if tap.TunnelId {
res.TunnelId = [8]byte{
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
}
}
if tap.Ipv4Src {
res.Ipv4Src = [4]byte{0xff, 0xff, 0xff, 0xff}
}
if tap.Ipv4Dst {
res.Ipv4Dst = [4]byte{0xff, 0xff, 0xff, 0xff}
}
if tap.Tos {
... | [
"func",
"(",
"tap",
"TunnelAttrsPresence",
")",
"mask",
"(",
")",
"(",
"res",
"TunnelAttrs",
")",
"{",
"if",
"tap",
".",
"TunnelId",
"{",
"res",
".",
"TunnelId",
"=",
"[",
"8",
"]",
"byte",
"{",
"0xff",
",",
"0xff",
",",
"0xff",
",",
"0xff",
",",
... | // Convert a TunnelAttrsPresence to a mask | [
"Convert",
"a",
"TunnelAttrsPresence",
"to",
"a",
"mask"
] | 6b0aa22550d9325eb8f43418185859e13dc0de1d | https://github.com/weaveworks/go-odp/blob/6b0aa22550d9325eb8f43418185859e13dc0de1d/odp/flow.go#L557-L593 |
132,854 | weaveworks/go-odp | odp/netlink.go | expand | func expand(buf []byte, l int) []byte {
c := (cap(buf) + 1) * 3 / 2
for l > c {
c = (c + 1) * 3 / 2
}
new := MakeAlignedByteSliceCap(len(buf), c)
copy(new, buf)
return new
} | go | func expand(buf []byte, l int) []byte {
c := (cap(buf) + 1) * 3 / 2
for l > c {
c = (c + 1) * 3 / 2
}
new := MakeAlignedByteSliceCap(len(buf), c)
copy(new, buf)
return new
} | [
"func",
"expand",
"(",
"buf",
"[",
"]",
"byte",
",",
"l",
"int",
")",
"[",
"]",
"byte",
"{",
"c",
":=",
"(",
"cap",
"(",
"buf",
")",
"+",
"1",
")",
"*",
"3",
"/",
"2",
"\n",
"for",
"l",
">",
"c",
"{",
"c",
"=",
"(",
"c",
"+",
"1",
")"... | // Expand the array underlying a slice to have capacity of at least l | [
"Expand",
"the",
"array",
"underlying",
"a",
"slice",
"to",
"have",
"capacity",
"of",
"at",
"least",
"l"
] | 6b0aa22550d9325eb8f43418185859e13dc0de1d | https://github.com/weaveworks/go-odp/blob/6b0aa22550d9325eb8f43418185859e13dc0de1d/odp/netlink.go#L97-L105 |
132,855 | weaveworks/go-odp | odp/netlink.go | Request | func (s *NetlinkSocket) Request(req *NlMsgBuilder) (resp *NlMsgParser, err error) {
seq, err := s.send(req)
if err != nil {
return nil, err
}
err = s.Receive(func(msg *NlMsgParser) (bool, error) {
relevant, err := msg.checkResponseHeader(s.PortId(), seq)
if relevant && err == nil {
resp = msg
}
return... | go | func (s *NetlinkSocket) Request(req *NlMsgBuilder) (resp *NlMsgParser, err error) {
seq, err := s.send(req)
if err != nil {
return nil, err
}
err = s.Receive(func(msg *NlMsgParser) (bool, error) {
relevant, err := msg.checkResponseHeader(s.PortId(), seq)
if relevant && err == nil {
resp = msg
}
return... | [
"func",
"(",
"s",
"*",
"NetlinkSocket",
")",
"Request",
"(",
"req",
"*",
"NlMsgBuilder",
")",
"(",
"resp",
"*",
"NlMsgParser",
",",
"err",
"error",
")",
"{",
"seq",
",",
"err",
":=",
"s",
".",
"send",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"ni... | // Do a netlink request that yields a single response message. | [
"Do",
"a",
"netlink",
"request",
"that",
"yields",
"a",
"single",
"response",
"message",
"."
] | 6b0aa22550d9325eb8f43418185859e13dc0de1d | https://github.com/weaveworks/go-odp/blob/6b0aa22550d9325eb8f43418185859e13dc0de1d/odp/netlink.go#L611-L625 |
132,856 | weaveworks/go-odp | odp/netlink.go | RequestMulti | func (s *NetlinkSocket) RequestMulti(req *NlMsgBuilder, consumer func(*NlMsgParser) error) error {
seq, err := s.send(req)
if err != nil {
return err
}
return s.Receive(func(msg *NlMsgParser) (bool, error) {
relevant, err := msg.checkResponseHeader(s.PortId(), seq)
if !relevant || err != nil {
return fals... | go | func (s *NetlinkSocket) RequestMulti(req *NlMsgBuilder, consumer func(*NlMsgParser) error) error {
seq, err := s.send(req)
if err != nil {
return err
}
return s.Receive(func(msg *NlMsgParser) (bool, error) {
relevant, err := msg.checkResponseHeader(s.PortId(), seq)
if !relevant || err != nil {
return fals... | [
"func",
"(",
"s",
"*",
"NetlinkSocket",
")",
"RequestMulti",
"(",
"req",
"*",
"NlMsgBuilder",
",",
"consumer",
"func",
"(",
"*",
"NlMsgParser",
")",
"error",
")",
"error",
"{",
"seq",
",",
"err",
":=",
"s",
".",
"send",
"(",
"req",
")",
"\n",
"if",
... | // Do a netlink request that yield multiple response messages. | [
"Do",
"a",
"netlink",
"request",
"that",
"yield",
"multiple",
"response",
"messages",
"."
] | 6b0aa22550d9325eb8f43418185859e13dc0de1d | https://github.com/weaveworks/go-odp/blob/6b0aa22550d9325eb8f43418185859e13dc0de1d/odp/netlink.go#L630-L653 |
132,857 | weaveworks/go-odp | odp/dpif.go | loadOpenvswitchModule | func loadOpenvswitchModule() {
if triedLoadOpenvswitchModule {
return
}
// netdev ioctls don't seem to work on netlink sockets, so we
// need a new socket for this purpose.
s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, 0)
if err != nil {
triedLoadOpenvswitchModule = true
return
}
defer s... | go | func loadOpenvswitchModule() {
if triedLoadOpenvswitchModule {
return
}
// netdev ioctls don't seem to work on netlink sockets, so we
// need a new socket for this purpose.
s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, 0)
if err != nil {
triedLoadOpenvswitchModule = true
return
}
defer s... | [
"func",
"loadOpenvswitchModule",
"(",
")",
"{",
"if",
"triedLoadOpenvswitchModule",
"{",
"return",
"\n",
"}",
"\n\n",
"// netdev ioctls don't seem to work on netlink sockets, so we",
"// need a new socket for this purpose.",
"s",
",",
"err",
":=",
"syscall",
".",
"Socket",
... | // This tries to provoke the kernel into loading the openvswitch
// module. Yes, netdev ioctls can be used to load arbitrary modules,
// if you have CAP_SYS_MODULE. | [
"This",
"tries",
"to",
"provoke",
"the",
"kernel",
"into",
"loading",
"the",
"openvswitch",
"module",
".",
"Yes",
"netdev",
"ioctls",
"can",
"be",
"used",
"to",
"load",
"arbitrary",
"modules",
"if",
"you",
"have",
"CAP_SYS_MODULE",
"."
] | 6b0aa22550d9325eb8f43418185859e13dc0de1d | https://github.com/weaveworks/go-odp/blob/6b0aa22550d9325eb8f43418185859e13dc0de1d/odp/dpif.go#L70-L90 |
132,858 | weaveworks/go-odp | odp/dpif.go | Reopen | func (dpif *Dpif) Reopen() (*Dpif, error) {
sock, err := OpenNetlinkSocket(syscall.NETLINK_GENERIC)
if err != nil {
return nil, err
}
return &Dpif{sock: sock, families: dpif.families}, nil
} | go | func (dpif *Dpif) Reopen() (*Dpif, error) {
sock, err := OpenNetlinkSocket(syscall.NETLINK_GENERIC)
if err != nil {
return nil, err
}
return &Dpif{sock: sock, families: dpif.families}, nil
} | [
"func",
"(",
"dpif",
"*",
"Dpif",
")",
"Reopen",
"(",
")",
"(",
"*",
"Dpif",
",",
"error",
")",
"{",
"sock",
",",
"err",
":=",
"OpenNetlinkSocket",
"(",
"syscall",
".",
"NETLINK_GENERIC",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"... | // Open a dpif with a new socket, but reuing the family info | [
"Open",
"a",
"dpif",
"with",
"a",
"new",
"socket",
"but",
"reuing",
"the",
"family",
"info"
] | 6b0aa22550d9325eb8f43418185859e13dc0de1d | https://github.com/weaveworks/go-odp/blob/6b0aa22550d9325eb8f43418185859e13dc0de1d/odp/dpif.go#L112-L119 |
132,859 | cloudfoundry/bosh-gcscli | config/config.go | FitCompatibleLocation | func (c *GCSCli) FitCompatibleLocation(loc string) error {
if c.StorageClass == "" {
var err error
if c.StorageClass, err = getDefaultStorageClass(loc); err != nil {
return err
}
}
_, regional := GCSRegionalLocations[loc]
_, multiRegional := GCSMultiRegionalLocations[loc]
if !(regional || multiRegional) ... | go | func (c *GCSCli) FitCompatibleLocation(loc string) error {
if c.StorageClass == "" {
var err error
if c.StorageClass, err = getDefaultStorageClass(loc); err != nil {
return err
}
}
_, regional := GCSRegionalLocations[loc]
_, multiRegional := GCSMultiRegionalLocations[loc]
if !(regional || multiRegional) ... | [
"func",
"(",
"c",
"*",
"GCSCli",
")",
"FitCompatibleLocation",
"(",
"loc",
"string",
")",
"error",
"{",
"if",
"c",
".",
"StorageClass",
"==",
"\"",
"\"",
"{",
"var",
"err",
"error",
"\n",
"if",
"c",
".",
"StorageClass",
",",
"err",
"=",
"getDefaultStor... | // FitCompatibleLocation returns whether a provided Location
// can have c.StorageClass objects written to it.
//
// When c.StorageClass is empty, a compatible default is filled in.
//
// nil return value when compatible, otherwise a non-nil explanation. | [
"FitCompatibleLocation",
"returns",
"whether",
"a",
"provided",
"Location",
"can",
"have",
"c",
".",
"StorageClass",
"objects",
"written",
"to",
"it",
".",
"When",
"c",
".",
"StorageClass",
"is",
"empty",
"a",
"compatible",
"default",
"is",
"filled",
"in",
"."... | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/config/config.go#L127-L146 |
132,860 | cloudfoundry/bosh-gcscli | integration/assertions.go | AssertLifecycleWorks | func AssertLifecycleWorks(gcsCLIPath string, ctx AssertContext) {
session, err := RunGCSCLI(gcsCLIPath, ctx.ConfigPath,
"put", ctx.ContentFile, ctx.GCSFileName)
Expect(err).ToNot(HaveOccurred())
Expect(session.ExitCode()).To(BeZero())
session, err = RunGCSCLI(gcsCLIPath, ctx.ConfigPath,
"exists", ctx.GCSFileNa... | go | func AssertLifecycleWorks(gcsCLIPath string, ctx AssertContext) {
session, err := RunGCSCLI(gcsCLIPath, ctx.ConfigPath,
"put", ctx.ContentFile, ctx.GCSFileName)
Expect(err).ToNot(HaveOccurred())
Expect(session.ExitCode()).To(BeZero())
session, err = RunGCSCLI(gcsCLIPath, ctx.ConfigPath,
"exists", ctx.GCSFileNa... | [
"func",
"AssertLifecycleWorks",
"(",
"gcsCLIPath",
"string",
",",
"ctx",
"AssertContext",
")",
"{",
"session",
",",
"err",
":=",
"RunGCSCLI",
"(",
"gcsCLIPath",
",",
"ctx",
".",
"ConfigPath",
",",
"\"",
"\"",
",",
"ctx",
".",
"ContentFile",
",",
"ctx",
"."... | // AssertLifecycleWorks tests the main blobstore object lifecycle from
// creation to deletion.
//
// This is using gomega matchers, so it will fail if called outside an
// 'It' test. | [
"AssertLifecycleWorks",
"tests",
"the",
"main",
"blobstore",
"object",
"lifecycle",
"from",
"creation",
"to",
"deletion",
".",
"This",
"is",
"using",
"gomega",
"matchers",
"so",
"it",
"will",
"fail",
"if",
"called",
"outside",
"an",
"It",
"test",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/assertions.go#L40-L77 |
132,861 | cloudfoundry/bosh-gcscli | integration/assertcontext.go | NewAssertContext | func NewAssertContext(options ...AssertContextConfigOption) AssertContext {
expectedString := GenerateRandomString()
serviceAccountFile := os.Getenv(ServiceAccountFileEnv)
Expect(serviceAccountFile).ToNot(BeEmpty(),
fmt.Sprintf(ServiceAccountFileMsg, ServiceAccountFileEnv))
return AssertContext{
ExpectedStrin... | go | func NewAssertContext(options ...AssertContextConfigOption) AssertContext {
expectedString := GenerateRandomString()
serviceAccountFile := os.Getenv(ServiceAccountFileEnv)
Expect(serviceAccountFile).ToNot(BeEmpty(),
fmt.Sprintf(ServiceAccountFileMsg, ServiceAccountFileEnv))
return AssertContext{
ExpectedStrin... | [
"func",
"NewAssertContext",
"(",
"options",
"...",
"AssertContextConfigOption",
")",
"AssertContext",
"{",
"expectedString",
":=",
"GenerateRandomString",
"(",
")",
"\n\n",
"serviceAccountFile",
":=",
"os",
".",
"Getenv",
"(",
"ServiceAccountFileEnv",
")",
"\n",
"Expe... | // NewAssertContext returns an AssertContext with all fields
// which can be generated filled in. | [
"NewAssertContext",
"returns",
"an",
"AssertContext",
"with",
"all",
"fields",
"which",
"can",
"be",
"generated",
"filled",
"in",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/assertcontext.go#L80-L95 |
132,862 | cloudfoundry/bosh-gcscli | integration/assertcontext.go | AddConfig | func (ctx *AssertContext) AddConfig(config *config.GCSCli) {
ctx.Config = config
for _, opt := range ctx.options {
opt(ctx)
}
ctx.ConfigPath = MakeConfigFile(ctx.Config)
} | go | func (ctx *AssertContext) AddConfig(config *config.GCSCli) {
ctx.Config = config
for _, opt := range ctx.options {
opt(ctx)
}
ctx.ConfigPath = MakeConfigFile(ctx.Config)
} | [
"func",
"(",
"ctx",
"*",
"AssertContext",
")",
"AddConfig",
"(",
"config",
"*",
"config",
".",
"GCSCli",
")",
"{",
"ctx",
".",
"Config",
"=",
"config",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"ctx",
".",
"options",
"{",
"opt",
"(",
"ctx",
")",... | // AddConfig includes the config.GCSCli required for AssertContext
//
// Configuration is typically not available immediately before a test
// can be run, hence the need to add it later. | [
"AddConfig",
"includes",
"the",
"config",
".",
"GCSCli",
"required",
"for",
"AssertContext",
"Configuration",
"is",
"typically",
"not",
"available",
"immediately",
"before",
"a",
"test",
"can",
"be",
"run",
"hence",
"the",
"need",
"to",
"add",
"it",
"later",
"... | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/assertcontext.go#L101-L107 |
132,863 | cloudfoundry/bosh-gcscli | integration/assertcontext.go | AsReadOnlyCredentials | func AsReadOnlyCredentials(ctx *AssertContext) {
conf := ctx.Config
Expect(conf).ToNot(BeNil(),
"cannot set read-only AssertContext without config")
conf.CredentialsSource = config.NoneCredentialsSource
conf.ServiceAccountFile = ""
} | go | func AsReadOnlyCredentials(ctx *AssertContext) {
conf := ctx.Config
Expect(conf).ToNot(BeNil(),
"cannot set read-only AssertContext without config")
conf.CredentialsSource = config.NoneCredentialsSource
conf.ServiceAccountFile = ""
} | [
"func",
"AsReadOnlyCredentials",
"(",
"ctx",
"*",
"AssertContext",
")",
"{",
"conf",
":=",
"ctx",
".",
"Config",
"\n",
"Expect",
"(",
"conf",
")",
".",
"ToNot",
"(",
"BeNil",
"(",
")",
",",
"\"",
"\"",
")",
"\n\n",
"conf",
".",
"CredentialsSource",
"="... | // AsReadOnlyCredentials configures the AssertContext to be used soley for
// public, read-only operations. | [
"AsReadOnlyCredentials",
"configures",
"the",
"AssertContext",
"to",
"be",
"used",
"soley",
"for",
"public",
"read",
"-",
"only",
"operations",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/assertcontext.go#L117-L124 |
132,864 | cloudfoundry/bosh-gcscli | integration/assertcontext.go | AsStaticCredentials | func AsStaticCredentials(ctx *AssertContext) {
conf := ctx.Config
Expect(conf).ToNot(BeNil(),
"cannot set static AssertContext without config")
conf.ServiceAccountFile = ctx.serviceAccountFile
conf.CredentialsSource = config.ServiceAccountFileCredentialsSource
} | go | func AsStaticCredentials(ctx *AssertContext) {
conf := ctx.Config
Expect(conf).ToNot(BeNil(),
"cannot set static AssertContext without config")
conf.ServiceAccountFile = ctx.serviceAccountFile
conf.CredentialsSource = config.ServiceAccountFileCredentialsSource
} | [
"func",
"AsStaticCredentials",
"(",
"ctx",
"*",
"AssertContext",
")",
"{",
"conf",
":=",
"ctx",
".",
"Config",
"\n",
"Expect",
"(",
"conf",
")",
".",
"ToNot",
"(",
"BeNil",
"(",
")",
",",
"\"",
"\"",
")",
"\n\n",
"conf",
".",
"ServiceAccountFile",
"=",... | // AsStaticCredentials configures the AssertContext to authenticate explicitly
// using a Service Account File | [
"AsStaticCredentials",
"configures",
"the",
"AssertContext",
"to",
"authenticate",
"explicitly",
"using",
"a",
"Service",
"Account",
"File"
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/assertcontext.go#L128-L135 |
132,865 | cloudfoundry/bosh-gcscli | integration/assertcontext.go | AsDefaultCredentials | func AsDefaultCredentials(ctx *AssertContext) {
conf := ctx.Config
Expect(conf).ToNot(BeNil(),
"cannot set static AssertContext without config")
tempFile, err := ioutil.TempFile("", "bosh-gcscli-service-account-file")
Expect(err).ToNot(HaveOccurred())
defer tempFile.Close()
tempFile.WriteString(ctx.serviceAcc... | go | func AsDefaultCredentials(ctx *AssertContext) {
conf := ctx.Config
Expect(conf).ToNot(BeNil(),
"cannot set static AssertContext without config")
tempFile, err := ioutil.TempFile("", "bosh-gcscli-service-account-file")
Expect(err).ToNot(HaveOccurred())
defer tempFile.Close()
tempFile.WriteString(ctx.serviceAcc... | [
"func",
"AsDefaultCredentials",
"(",
"ctx",
"*",
"AssertContext",
")",
"{",
"conf",
":=",
"ctx",
".",
"Config",
"\n",
"Expect",
"(",
"conf",
")",
".",
"ToNot",
"(",
"BeNil",
"(",
")",
",",
"\"",
"\"",
")",
"\n\n",
"tempFile",
",",
"err",
":=",
"iouti... | // AsDefaultCredentials configures the AssertContext to authenticate using
// Application Default Credentials populated using the
// testing service account file. | [
"AsDefaultCredentials",
"configures",
"the",
"AssertContext",
"to",
"authenticate",
"using",
"Application",
"Default",
"Credentials",
"populated",
"using",
"the",
"testing",
"service",
"account",
"file",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/assertcontext.go#L140-L155 |
132,866 | cloudfoundry/bosh-gcscli | integration/assertcontext.go | Cleanup | func (ctx *AssertContext) Cleanup() {
os.Remove(ctx.ConfigPath)
os.Remove(ctx.ContentFile)
if ctx.serviceAccountPath != "" {
os.Remove(ctx.serviceAccountPath)
}
os.Unsetenv(GoogleAppCredentialsEnv)
} | go | func (ctx *AssertContext) Cleanup() {
os.Remove(ctx.ConfigPath)
os.Remove(ctx.ContentFile)
if ctx.serviceAccountPath != "" {
os.Remove(ctx.serviceAccountPath)
}
os.Unsetenv(GoogleAppCredentialsEnv)
} | [
"func",
"(",
"ctx",
"*",
"AssertContext",
")",
"Cleanup",
"(",
")",
"{",
"os",
".",
"Remove",
"(",
"ctx",
".",
"ConfigPath",
")",
"\n",
"os",
".",
"Remove",
"(",
"ctx",
".",
"ContentFile",
")",
"\n\n",
"if",
"ctx",
".",
"serviceAccountPath",
"!=",
"\... | // Cleanup removes artifacts generated by the AssertContext. | [
"Cleanup",
"removes",
"artifacts",
"generated",
"by",
"the",
"AssertContext",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/assertcontext.go#L176-L184 |
132,867 | cloudfoundry/bosh-gcscli | config/regions.go | validLocationStorageClass | func validLocationStorageClass(location, storageClass string) error {
if _, ok := GCSStorageClass[storageClass]; !ok {
return ErrUnknownStorageClass
}
if storageClass == regional {
if _, ok := GCSMultiRegionalLocations[location]; ok {
return ErrBadLocationStorageClass
}
return nil
} else if _, ok := GCS... | go | func validLocationStorageClass(location, storageClass string) error {
if _, ok := GCSStorageClass[storageClass]; !ok {
return ErrUnknownStorageClass
}
if storageClass == regional {
if _, ok := GCSMultiRegionalLocations[location]; ok {
return ErrBadLocationStorageClass
}
return nil
} else if _, ok := GCS... | [
"func",
"validLocationStorageClass",
"(",
"location",
",",
"storageClass",
"string",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"GCSStorageClass",
"[",
"storageClass",
"]",
";",
"!",
"ok",
"{",
"return",
"ErrUnknownStorageClass",
"\n",
"}",
"\n\n",
"if",
... | // validDurability returns nil error on valid location-durability combination
// and non-nil explanation on all else. | [
"validDurability",
"returns",
"nil",
"error",
"on",
"valid",
"location",
"-",
"durability",
"combination",
"and",
"non",
"-",
"nil",
"explanation",
"on",
"all",
"else",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/config/regions.go#L72-L90 |
132,868 | cloudfoundry/bosh-gcscli | client/client.go | validateRemoteConfig | func (client *GCSBlobstore) validateRemoteConfig() error {
if client.readOnly() {
return nil
}
bucket := client.authenticatedGCS.Bucket(client.config.BucketName)
attrs, err := bucket.Attrs(context.Background())
if err != nil {
return err
}
return client.config.FitCompatibleLocation(attrs.Location)
} | go | func (client *GCSBlobstore) validateRemoteConfig() error {
if client.readOnly() {
return nil
}
bucket := client.authenticatedGCS.Bucket(client.config.BucketName)
attrs, err := bucket.Attrs(context.Background())
if err != nil {
return err
}
return client.config.FitCompatibleLocation(attrs.Location)
} | [
"func",
"(",
"client",
"*",
"GCSBlobstore",
")",
"validateRemoteConfig",
"(",
")",
"error",
"{",
"if",
"client",
".",
"readOnly",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"bucket",
":=",
"client",
".",
"authenticatedGCS",
".",
"Bucket",
"(",
"c... | // validateRemoteConfig determines if the configuration of the client matches
// against the remote configuration and the StorageClass is valid for the location.
//
// If operating in read-only mode, no mutations can be performed
// so the remote bucket location is always compatible. | [
"validateRemoteConfig",
"determines",
"if",
"the",
"configuration",
"of",
"the",
"client",
"matches",
"against",
"the",
"remote",
"configuration",
"and",
"the",
"StorageClass",
"is",
"valid",
"for",
"the",
"location",
".",
"If",
"operating",
"in",
"read",
"-",
"... | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/client/client.go#L47-L58 |
132,869 | cloudfoundry/bosh-gcscli | client/client.go | getObjectHandle | func (client *GCSBlobstore) getObjectHandle(gcs *storage.Client, src string) *storage.ObjectHandle {
handle := gcs.Bucket(client.config.BucketName).Object(src)
if client.config.EncryptionKey != nil {
handle = handle.Key(client.config.EncryptionKey)
}
return handle
} | go | func (client *GCSBlobstore) getObjectHandle(gcs *storage.Client, src string) *storage.ObjectHandle {
handle := gcs.Bucket(client.config.BucketName).Object(src)
if client.config.EncryptionKey != nil {
handle = handle.Key(client.config.EncryptionKey)
}
return handle
} | [
"func",
"(",
"client",
"*",
"GCSBlobstore",
")",
"getObjectHandle",
"(",
"gcs",
"*",
"storage",
".",
"Client",
",",
"src",
"string",
")",
"*",
"storage",
".",
"ObjectHandle",
"{",
"handle",
":=",
"gcs",
".",
"Bucket",
"(",
"client",
".",
"config",
".",
... | // getObjectHandle returns a handle to an object named src | [
"getObjectHandle",
"returns",
"a",
"handle",
"to",
"an",
"object",
"named",
"src"
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/client/client.go#L61-L67 |
132,870 | cloudfoundry/bosh-gcscli | client/client.go | New | func New(ctx context.Context, cfg *config.GCSCli) (*GCSBlobstore, error) {
if cfg == nil {
return nil, errors.New("expected non-nill config object")
}
authenticatedGCS, publicGCS, err := newStorageClients(ctx, cfg)
if err != nil {
return nil, fmt.Errorf("creating storage client: %v", err)
}
return &GCSBlobs... | go | func New(ctx context.Context, cfg *config.GCSCli) (*GCSBlobstore, error) {
if cfg == nil {
return nil, errors.New("expected non-nill config object")
}
authenticatedGCS, publicGCS, err := newStorageClients(ctx, cfg)
if err != nil {
return nil, fmt.Errorf("creating storage client: %v", err)
}
return &GCSBlobs... | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"cfg",
"*",
"config",
".",
"GCSCli",
")",
"(",
"*",
"GCSBlobstore",
",",
"error",
")",
"{",
"if",
"cfg",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")"... | // New returns a GCSBlobstore configured to operate using the given config
//
// non-nil error is returned on invalid Client or config. If the configuration
// is incompatible with the GCS bucket, a non-nil error is also returned. | [
"New",
"returns",
"a",
"GCSBlobstore",
"configured",
"to",
"operate",
"using",
"the",
"given",
"config",
"non",
"-",
"nil",
"error",
"is",
"returned",
"on",
"invalid",
"Client",
"or",
"config",
".",
"If",
"the",
"configuration",
"is",
"incompatible",
"with",
... | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/client/client.go#L73-L84 |
132,871 | cloudfoundry/bosh-gcscli | client/client.go | Get | func (client *GCSBlobstore) Get(src string, dest io.Writer) error {
reader, err := client.getReader(client.publicGCS, src)
// If the public client fails, try using it as an authenticated actor
if err != nil && client.authenticatedGCS != nil {
reader, err = client.getReader(client.authenticatedGCS, src)
}
if er... | go | func (client *GCSBlobstore) Get(src string, dest io.Writer) error {
reader, err := client.getReader(client.publicGCS, src)
// If the public client fails, try using it as an authenticated actor
if err != nil && client.authenticatedGCS != nil {
reader, err = client.getReader(client.authenticatedGCS, src)
}
if er... | [
"func",
"(",
"client",
"*",
"GCSBlobstore",
")",
"Get",
"(",
"src",
"string",
",",
"dest",
"io",
".",
"Writer",
")",
"error",
"{",
"reader",
",",
"err",
":=",
"client",
".",
"getReader",
"(",
"client",
".",
"publicGCS",
",",
"src",
")",
"\n\n",
"// I... | // Get fetches a blob from the GCS blobstore.
// Destination will be overwritten if it already exists. | [
"Get",
"fetches",
"a",
"blob",
"from",
"the",
"GCS",
"blobstore",
".",
"Destination",
"will",
"be",
"overwritten",
"if",
"it",
"already",
"exists",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/client/client.go#L88-L102 |
132,872 | cloudfoundry/bosh-gcscli | client/client.go | Delete | func (client *GCSBlobstore) Delete(dest string) error {
if client.readOnly() {
return ErrInvalidROWriteOperation
}
err := client.getObjectHandle(client.authenticatedGCS, dest).Delete(context.Background())
if err == storage.ErrObjectNotExist {
return nil
}
return err
} | go | func (client *GCSBlobstore) Delete(dest string) error {
if client.readOnly() {
return ErrInvalidROWriteOperation
}
err := client.getObjectHandle(client.authenticatedGCS, dest).Delete(context.Background())
if err == storage.ErrObjectNotExist {
return nil
}
return err
} | [
"func",
"(",
"client",
"*",
"GCSBlobstore",
")",
"Delete",
"(",
"dest",
"string",
")",
"error",
"{",
"if",
"client",
".",
"readOnly",
"(",
")",
"{",
"return",
"ErrInvalidROWriteOperation",
"\n",
"}",
"\n\n",
"err",
":=",
"client",
".",
"getObjectHandle",
"... | // Delete removes a blob from from the GCS blobstore.
//
// If the object does not exist, Delete returns a nil error. | [
"Delete",
"removes",
"a",
"blob",
"from",
"from",
"the",
"GCS",
"blobstore",
".",
"If",
"the",
"object",
"does",
"not",
"exist",
"Delete",
"returns",
"a",
"nil",
"error",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/client/client.go#L161-L171 |
132,873 | cloudfoundry/bosh-gcscli | client/client.go | Exists | func (client *GCSBlobstore) Exists(dest string) (exists bool, err error) {
if exists, err = client.exists(client.publicGCS, dest); err == nil {
return exists, nil
}
// If the public client fails, try using it as an authenticated actor
if client.authenticatedGCS != nil {
return client.exists(client.authenticate... | go | func (client *GCSBlobstore) Exists(dest string) (exists bool, err error) {
if exists, err = client.exists(client.publicGCS, dest); err == nil {
return exists, nil
}
// If the public client fails, try using it as an authenticated actor
if client.authenticatedGCS != nil {
return client.exists(client.authenticate... | [
"func",
"(",
"client",
"*",
"GCSBlobstore",
")",
"Exists",
"(",
"dest",
"string",
")",
"(",
"exists",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"exists",
",",
"err",
"=",
"client",
".",
"exists",
"(",
"client",
".",
"publicGCS",
",",
"dest",
")",
... | // Exists checks if a blob exists in the GCS blobstore. | [
"Exists",
"checks",
"if",
"a",
"blob",
"exists",
"in",
"the",
"GCS",
"blobstore",
"."
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/client/client.go#L174-L185 |
132,874 | cloudfoundry/bosh-gcscli | integration/utils.go | MakeConfigFile | func MakeConfigFile(cfg *config.GCSCli) string {
cfgBytes, err := json.Marshal(cfg)
Expect(err).ToNot(HaveOccurred())
tmpFile, err := ioutil.TempFile("", "gcscli-test")
Expect(err).ToNot(HaveOccurred())
_, err = tmpFile.Write(cfgBytes)
Expect(err).ToNot(HaveOccurred())
err = tmpFile.Close()
Expect(err).ToNot(Ha... | go | func MakeConfigFile(cfg *config.GCSCli) string {
cfgBytes, err := json.Marshal(cfg)
Expect(err).ToNot(HaveOccurred())
tmpFile, err := ioutil.TempFile("", "gcscli-test")
Expect(err).ToNot(HaveOccurred())
_, err = tmpFile.Write(cfgBytes)
Expect(err).ToNot(HaveOccurred())
err = tmpFile.Close()
Expect(err).ToNot(Ha... | [
"func",
"MakeConfigFile",
"(",
"cfg",
"*",
"config",
".",
"GCSCli",
")",
"string",
"{",
"cfgBytes",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"cfg",
")",
"\n",
"Expect",
"(",
"err",
")",
".",
"ToNot",
"(",
"HaveOccurred",
"(",
")",
")",
"\n",
... | // MakeConfigFile creates a config file from a GCSCli config struct | [
"MakeConfigFile",
"creates",
"a",
"config",
"file",
"from",
"a",
"GCSCli",
"config",
"struct"
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/utils.go#L50-L60 |
132,875 | cloudfoundry/bosh-gcscli | integration/utils.go | MakeContentFile | func MakeContentFile(content string) string {
tmpFile, err := ioutil.TempFile("", "gcscli-test-content")
Expect(err).ToNot(HaveOccurred())
_, err = tmpFile.Write([]byte(content))
Expect(err).ToNot(HaveOccurred())
err = tmpFile.Close()
Expect(err).ToNot(HaveOccurred())
return tmpFile.Name()
} | go | func MakeContentFile(content string) string {
tmpFile, err := ioutil.TempFile("", "gcscli-test-content")
Expect(err).ToNot(HaveOccurred())
_, err = tmpFile.Write([]byte(content))
Expect(err).ToNot(HaveOccurred())
err = tmpFile.Close()
Expect(err).ToNot(HaveOccurred())
return tmpFile.Name()
} | [
"func",
"MakeContentFile",
"(",
"content",
"string",
")",
"string",
"{",
"tmpFile",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"Expect",
"(",
"err",
")",
".",
"ToNot",
"(",
"HaveOccurred",
"(",
")",
")",... | // MakeContentFile creates a temporary file with content to upload to GCS | [
"MakeContentFile",
"creates",
"a",
"temporary",
"file",
"with",
"content",
"to",
"upload",
"to",
"GCS"
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/utils.go#L63-L71 |
132,876 | cloudfoundry/bosh-gcscli | integration/utils.go | RunGCSCLI | func RunGCSCLI(gcsCLIPath, configPath, subcommand string,
args ...string) (*gexec.Session, error) {
cmdArgs := []string{
"-c",
configPath,
subcommand,
}
cmdArgs = append(cmdArgs, args...)
command := exec.Command(gcsCLIPath, cmdArgs...)
gexecSession, err := gexec.Start(command,
ginkgo.GinkgoWriter, ginkg... | go | func RunGCSCLI(gcsCLIPath, configPath, subcommand string,
args ...string) (*gexec.Session, error) {
cmdArgs := []string{
"-c",
configPath,
subcommand,
}
cmdArgs = append(cmdArgs, args...)
command := exec.Command(gcsCLIPath, cmdArgs...)
gexecSession, err := gexec.Start(command,
ginkgo.GinkgoWriter, ginkg... | [
"func",
"RunGCSCLI",
"(",
"gcsCLIPath",
",",
"configPath",
",",
"subcommand",
"string",
",",
"args",
"...",
"string",
")",
"(",
"*",
"gexec",
".",
"Session",
",",
"error",
")",
"{",
"cmdArgs",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"configPath... | // RunGCSCLI run the gcscli and outputs the session
// after waiting for it to finish | [
"RunGCSCLI",
"run",
"the",
"gcscli",
"and",
"outputs",
"the",
"session",
"after",
"waiting",
"for",
"it",
"to",
"finish"
] | 2aef468b5b8561560918014b4fbce7549de2283d | https://github.com/cloudfoundry/bosh-gcscli/blob/2aef468b5b8561560918014b4fbce7549de2283d/integration/utils.go#L75-L94 |
132,877 | gotsunami/go-cloudinary | cloudinary/main.go | LoadConfig | func LoadConfig(path string) (*Config, error) {
settings := &Config{}
c, err := config.ReadDefault(path)
if err != nil {
return nil, err
}
// Cloudinary settings
var cURI *url.URL
var uri string
if uri, err = c.String("cloudinary", "uri"); err != nil {
return nil, err
}
if cURI, err = url.Parse(uri); e... | go | func LoadConfig(path string) (*Config, error) {
settings := &Config{}
c, err := config.ReadDefault(path)
if err != nil {
return nil, err
}
// Cloudinary settings
var cURI *url.URL
var uri string
if uri, err = c.String("cloudinary", "uri"); err != nil {
return nil, err
}
if cURI, err = url.Parse(uri); e... | [
"func",
"LoadConfig",
"(",
"path",
"string",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"settings",
":=",
"&",
"Config",
"{",
"}",
"\n\n",
"c",
",",
"err",
":=",
"config",
".",
"ReadDefault",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // LoadConfig parses a config file and sets global settings
// variables to be used at runtime. Note that returning an error
// will cause the application to exit with code error 1. | [
"LoadConfig",
"parses",
"a",
"config",
"file",
"and",
"sets",
"global",
"settings",
"variables",
"to",
"be",
"used",
"at",
"runtime",
".",
"Note",
"that",
"returning",
"an",
"error",
"will",
"cause",
"the",
"application",
"to",
"exit",
"with",
"code",
"error... | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/cloudinary/main.go#L85-L135 |
132,878 | gotsunami/go-cloudinary | admin.go | DropAllImages | func (s *Service) DropAllImages(w io.Writer) error {
return s.dropAllResources(ImageType, w)
} | go | func (s *Service) DropAllImages(w io.Writer) error {
return s.dropAllResources(ImageType, w)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"DropAllImages",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"s",
".",
"dropAllResources",
"(",
"ImageType",
",",
"w",
")",
"\n",
"}"
] | // DropAllImages deletes all remote images from Cloudinary. File names are
// written to io.Writer if available. | [
"DropAllImages",
"deletes",
"all",
"remote",
"images",
"from",
"Cloudinary",
".",
"File",
"names",
"are",
"written",
"to",
"io",
".",
"Writer",
"if",
"available",
"."
] | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/admin.go#L69-L71 |
132,879 | gotsunami/go-cloudinary | admin.go | DropAllRaws | func (s *Service) DropAllRaws(w io.Writer) error {
return s.dropAllResources(RawType, w)
} | go | func (s *Service) DropAllRaws(w io.Writer) error {
return s.dropAllResources(RawType, w)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"DropAllRaws",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"s",
".",
"dropAllResources",
"(",
"RawType",
",",
"w",
")",
"\n",
"}"
] | // DropAllRaws deletes all remote raw files from Cloudinary. File names are
// written to io.Writer if available. | [
"DropAllRaws",
"deletes",
"all",
"remote",
"raw",
"files",
"from",
"Cloudinary",
".",
"File",
"names",
"are",
"written",
"to",
"io",
".",
"Writer",
"if",
"available",
"."
] | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/admin.go#L75-L77 |
132,880 | gotsunami/go-cloudinary | admin.go | Resources | func (s *Service) Resources(rtype ResourceType) ([]*Resource, error) {
return s.doGetResources(rtype)
} | go | func (s *Service) Resources(rtype ResourceType) ([]*Resource, error) {
return s.doGetResources(rtype)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"Resources",
"(",
"rtype",
"ResourceType",
")",
"(",
"[",
"]",
"*",
"Resource",
",",
"error",
")",
"{",
"return",
"s",
".",
"doGetResources",
"(",
"rtype",
")",
"\n",
"}"
] | // Resources returns a list of all uploaded resources. They can be
// images or raw files, depending on the resource type passed in rtype.
// Cloudinary can return a limited set of results. Pagination is supported,
// so the full set of results is returned. | [
"Resources",
"returns",
"a",
"list",
"of",
"all",
"uploaded",
"resources",
".",
"They",
"can",
"be",
"images",
"or",
"raw",
"files",
"depending",
"on",
"the",
"resource",
"type",
"passed",
"in",
"rtype",
".",
"Cloudinary",
"can",
"return",
"a",
"limited",
... | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/admin.go#L145-L147 |
132,881 | gotsunami/go-cloudinary | admin.go | ResourceDetails | func (s *Service) ResourceDetails(publicId string) (*ResourceDetails, error) {
return s.doGetResourceDetails(publicId)
} | go | func (s *Service) ResourceDetails(publicId string) (*ResourceDetails, error) {
return s.doGetResourceDetails(publicId)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"ResourceDetails",
"(",
"publicId",
"string",
")",
"(",
"*",
"ResourceDetails",
",",
"error",
")",
"{",
"return",
"s",
".",
"doGetResourceDetails",
"(",
"publicId",
")",
"\n",
"}"
] | // GetResourceDetails gets the details of a single resource that is specified by publicId. | [
"GetResourceDetails",
"gets",
"the",
"details",
"of",
"a",
"single",
"resource",
"that",
"is",
"specified",
"by",
"publicId",
"."
] | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/admin.go#L150-L152 |
132,882 | gotsunami/go-cloudinary | service.go | Url | func (s *Service) Url(publicId string, rtype ResourceType) string {
path := imageType
if rtype == PdfType {
path = pdfType
} else if rtype == VideoType {
path = videoType
} else if rtype == RawType {
path = rawType
}
return fmt.Sprintf("%s/%s/%s/upload/%s", baseResourceUrl, s.cloudName, path, publicId)
} | go | func (s *Service) Url(publicId string, rtype ResourceType) string {
path := imageType
if rtype == PdfType {
path = pdfType
} else if rtype == VideoType {
path = videoType
} else if rtype == RawType {
path = rawType
}
return fmt.Sprintf("%s/%s/%s/upload/%s", baseResourceUrl, s.cloudName, path, publicId)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"Url",
"(",
"publicId",
"string",
",",
"rtype",
"ResourceType",
")",
"string",
"{",
"path",
":=",
"imageType",
"\n",
"if",
"rtype",
"==",
"PdfType",
"{",
"path",
"=",
"pdfType",
"\n",
"}",
"else",
"if",
"rtype",
... | // Url returns the complete access path in the cloud to the
// resource designed by publicId or the empty string if
// no match. | [
"Url",
"returns",
"the",
"complete",
"access",
"path",
"in",
"the",
"cloud",
"to",
"the",
"resource",
"designed",
"by",
"publicId",
"or",
"the",
"empty",
"string",
"if",
"no",
"match",
"."
] | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/service.go#L536-L546 |
132,883 | gotsunami/go-cloudinary | service.go | Delete | func (s *Service) Delete(publicId, prepend string, rtype ResourceType) error {
// TODO: also delete resource entry from database (if used)
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
data := url.Values{
"api_key": []string{s.apiKey},
"public_id": []string{prepend + publicId},
"timestamp": []string{... | go | func (s *Service) Delete(publicId, prepend string, rtype ResourceType) error {
// TODO: also delete resource entry from database (if used)
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
data := url.Values{
"api_key": []string{s.apiKey},
"public_id": []string{prepend + publicId},
"timestamp": []string{... | [
"func",
"(",
"s",
"*",
"Service",
")",
"Delete",
"(",
"publicId",
",",
"prepend",
"string",
",",
"rtype",
"ResourceType",
")",
"error",
"{",
"// TODO: also delete resource entry from database (if used)",
"timestamp",
":=",
"strconv",
".",
"FormatInt",
"(",
"time",
... | // Delete deletes a resource uploaded to Cloudinary. | [
"Delete",
"deletes",
"a",
"resource",
"uploaded",
"to",
"Cloudinary",
"."
] | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/service.go#L569-L617 |
132,884 | gotsunami/go-cloudinary | tools.go | fileChecksum | func fileChecksum(path string) (string, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
hash := sha1.New()
io.WriteString(hash, string(data))
return fmt.Sprintf("%x", hash.Sum(nil)), nil
} | go | func fileChecksum(path string) (string, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
hash := sha1.New()
io.WriteString(hash, string(data))
return fmt.Sprintf("%x", hash.Sum(nil)), nil
} | [
"func",
"fileChecksum",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\... | // Returns SHA1 file checksum | [
"Returns",
"SHA1",
"file",
"checksum"
] | 0ed519cc11198391764646f7c247e951e735ca6a | https://github.com/gotsunami/go-cloudinary/blob/0ed519cc11198391764646f7c247e951e735ca6a/tools.go#L16-L24 |
132,885 | zfjagann/golang-ring | ring.go | set | func (r *Ring) set(p int, v interface{}) {
r.buff[r.mod(p)] = v
} | go | func (r *Ring) set(p int, v interface{}) {
r.buff[r.mod(p)] = v
} | [
"func",
"(",
"r",
"*",
"Ring",
")",
"set",
"(",
"p",
"int",
",",
"v",
"interface",
"{",
"}",
")",
"{",
"r",
".",
"buff",
"[",
"r",
".",
"mod",
"(",
"p",
")",
"]",
"=",
"v",
"\n",
"}"
] | // sets a value at the given unmodified index and returns the modified index of the value | [
"sets",
"a",
"value",
"at",
"the",
"given",
"unmodified",
"index",
"and",
"returns",
"the",
"modified",
"index",
"of",
"the",
"value"
] | d34796e0a6c20df67b614d69184ee4c8093a6856 | https://github.com/zfjagann/golang-ring/blob/d34796e0a6c20df67b614d69184ee4c8093a6856/ring.go#L152-L154 |
132,886 | zfjagann/golang-ring | ring.go | get | func (r *Ring) get(p int) interface{} {
return r.buff[r.mod(p)]
} | go | func (r *Ring) get(p int) interface{} {
return r.buff[r.mod(p)]
} | [
"func",
"(",
"r",
"*",
"Ring",
")",
"get",
"(",
"p",
"int",
")",
"interface",
"{",
"}",
"{",
"return",
"r",
".",
"buff",
"[",
"r",
".",
"mod",
"(",
"p",
")",
"]",
"\n",
"}"
] | // gets a value based at a given unmodified index | [
"gets",
"a",
"value",
"based",
"at",
"a",
"given",
"unmodified",
"index"
] | d34796e0a6c20df67b614d69184ee4c8093a6856 | https://github.com/zfjagann/golang-ring/blob/d34796e0a6c20df67b614d69184ee4c8093a6856/ring.go#L157-L159 |
132,887 | zfjagann/golang-ring | ring.go | mod | func (r *Ring) mod(p int) int {
return p % len(r.buff)
} | go | func (r *Ring) mod(p int) int {
return p % len(r.buff)
} | [
"func",
"(",
"r",
"*",
"Ring",
")",
"mod",
"(",
"p",
"int",
")",
"int",
"{",
"return",
"p",
"%",
"len",
"(",
"r",
".",
"buff",
")",
"\n",
"}"
] | // returns the modified index of an unmodified index | [
"returns",
"the",
"modified",
"index",
"of",
"an",
"unmodified",
"index"
] | d34796e0a6c20df67b614d69184ee4c8093a6856 | https://github.com/zfjagann/golang-ring/blob/d34796e0a6c20df67b614d69184ee4c8093a6856/ring.go#L162-L164 |
132,888 | rfjakob/eme | eme.go | multByTwo | func multByTwo(out []byte, in []byte) {
if len(in) != 16 {
panic("len must be 16")
}
tmp := make([]byte, 16)
tmp[0] = 2 * in[0]
if in[15] >= 128 {
tmp[0] = tmp[0] ^ 135
}
for j := 1; j < 16; j++ {
tmp[j] = 2 * in[j]
if in[j-1] >= 128 {
tmp[j] += 1
}
}
copy(out, tmp)
} | go | func multByTwo(out []byte, in []byte) {
if len(in) != 16 {
panic("len must be 16")
}
tmp := make([]byte, 16)
tmp[0] = 2 * in[0]
if in[15] >= 128 {
tmp[0] = tmp[0] ^ 135
}
for j := 1; j < 16; j++ {
tmp[j] = 2 * in[j]
if in[j-1] >= 128 {
tmp[j] += 1
}
}
copy(out, tmp)
} | [
"func",
"multByTwo",
"(",
"out",
"[",
"]",
"byte",
",",
"in",
"[",
"]",
"byte",
")",
"{",
"if",
"len",
"(",
"in",
")",
"!=",
"16",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"tmp",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"16",
... | // multByTwo - GF multiplication as specified in the EME-32 draft | [
"multByTwo",
"-",
"GF",
"multiplication",
"as",
"specified",
"in",
"the",
"EME",
"-",
"32",
"draft"
] | 2222dbd4ba467ab3fc7e8af41562fcfe69c0d770 | https://github.com/rfjakob/eme/blob/2222dbd4ba467ab3fc7e8af41562fcfe69c0d770/eme.go#L26-L43 |
132,889 | rfjakob/eme | eme.go | tabulateL | func tabulateL(bc cipher.Block, m int) [][]byte {
/* set L0 = 2*AESenc(K; 0) */
eZero := make([]byte, 16)
Li := make([]byte, 16)
bc.Encrypt(Li, eZero)
LTable := make([][]byte, m)
// Allocate pool once and slice into m pieces in the loop
pool := make([]byte, m*16)
for i := 0; i < m; i++ {
multByTwo(Li, Li)
... | go | func tabulateL(bc cipher.Block, m int) [][]byte {
/* set L0 = 2*AESenc(K; 0) */
eZero := make([]byte, 16)
Li := make([]byte, 16)
bc.Encrypt(Li, eZero)
LTable := make([][]byte, m)
// Allocate pool once and slice into m pieces in the loop
pool := make([]byte, m*16)
for i := 0; i < m; i++ {
multByTwo(Li, Li)
... | [
"func",
"tabulateL",
"(",
"bc",
"cipher",
".",
"Block",
",",
"m",
"int",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"/* set L0 = 2*AESenc(K; 0) */",
"eZero",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"16",
")",
"\n",
"Li",
":=",
"make",
"(",
"[",
"]",
... | // tabulateL - calculate L_i for messages up to a length of m cipher blocks | [
"tabulateL",
"-",
"calculate",
"L_i",
"for",
"messages",
"up",
"to",
"a",
"length",
"of",
"m",
"cipher",
"blocks"
] | 2222dbd4ba467ab3fc7e8af41562fcfe69c0d770 | https://github.com/rfjakob/eme/blob/2222dbd4ba467ab3fc7e8af41562fcfe69c0d770/eme.go#L68-L83 |
132,890 | rfjakob/eme | eme.go | Encrypt | func (e *EMECipher) Encrypt(tweak []byte, inputData []byte) []byte {
return Transform(e.bc, tweak, inputData, DirectionEncrypt)
} | go | func (e *EMECipher) Encrypt(tweak []byte, inputData []byte) []byte {
return Transform(e.bc, tweak, inputData, DirectionEncrypt)
} | [
"func",
"(",
"e",
"*",
"EMECipher",
")",
"Encrypt",
"(",
"tweak",
"[",
"]",
"byte",
",",
"inputData",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"Transform",
"(",
"e",
".",
"bc",
",",
"tweak",
",",
"inputData",
",",
"DirectionEncrypt",
... | // Encrypt is equivalent to calling Transform with direction=DirectionEncrypt. | [
"Encrypt",
"is",
"equivalent",
"to",
"calling",
"Transform",
"with",
"direction",
"=",
"DirectionEncrypt",
"."
] | 2222dbd4ba467ab3fc7e8af41562fcfe69c0d770 | https://github.com/rfjakob/eme/blob/2222dbd4ba467ab3fc7e8af41562fcfe69c0d770/eme.go#L199-L201 |
132,891 | rfjakob/eme | eme.go | Decrypt | func (e *EMECipher) Decrypt(tweak []byte, inputData []byte) []byte {
return Transform(e.bc, tweak, inputData, DirectionDecrypt)
} | go | func (e *EMECipher) Decrypt(tweak []byte, inputData []byte) []byte {
return Transform(e.bc, tweak, inputData, DirectionDecrypt)
} | [
"func",
"(",
"e",
"*",
"EMECipher",
")",
"Decrypt",
"(",
"tweak",
"[",
"]",
"byte",
",",
"inputData",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"Transform",
"(",
"e",
".",
"bc",
",",
"tweak",
",",
"inputData",
",",
"DirectionDecrypt",
... | // Decrypt is equivalent to calling Transform with direction=DirectionDecrypt. | [
"Decrypt",
"is",
"equivalent",
"to",
"calling",
"Transform",
"with",
"direction",
"=",
"DirectionDecrypt",
"."
] | 2222dbd4ba467ab3fc7e8af41562fcfe69c0d770 | https://github.com/rfjakob/eme/blob/2222dbd4ba467ab3fc7e8af41562fcfe69c0d770/eme.go#L204-L206 |
132,892 | blockloop/scan | columns.go | Columns | func Columns(v interface{}, excluded ...string) ([]string, error) {
return columns(v, false, excluded...)
} | go | func Columns(v interface{}, excluded ...string) ([]string, error) {
return columns(v, false, excluded...)
} | [
"func",
"Columns",
"(",
"v",
"interface",
"{",
"}",
",",
"excluded",
"...",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"columns",
"(",
"v",
",",
"false",
",",
"excluded",
"...",
")",
"\n",
"}"
] | // Columns scans a struct and returns a list of strings
// that represent the assumed column names based on the
// db struct tag, or the field name. Any field or struct
// tag that matches a string within the excluded list
// will be excluded from the result | [
"Columns",
"scans",
"a",
"struct",
"and",
"returns",
"a",
"list",
"of",
"strings",
"that",
"represent",
"the",
"assumed",
"column",
"names",
"based",
"on",
"the",
"db",
"struct",
"tag",
"or",
"the",
"field",
"name",
".",
"Any",
"field",
"or",
"struct",
"... | 2e129a9c2603efc4380c7b7d318785b4ff6803ab | https://github.com/blockloop/scan/blob/2e129a9c2603efc4380c7b7d318785b4ff6803ab/columns.go#L18-L20 |
132,893 | blockloop/scan | columns.go | ColumnsStrict | func ColumnsStrict(v interface{}, excluded ...string) ([]string, error) {
return columns(v, true, excluded...)
} | go | func ColumnsStrict(v interface{}, excluded ...string) ([]string, error) {
return columns(v, true, excluded...)
} | [
"func",
"ColumnsStrict",
"(",
"v",
"interface",
"{",
"}",
",",
"excluded",
"...",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"columns",
"(",
"v",
",",
"true",
",",
"excluded",
"...",
")",
"\n",
"}"
] | // ColumnsStrict is identical to Columns, but it only
// searches struct tags and excludes fields not tagged
// with the db struct tag | [
"ColumnsStrict",
"is",
"identical",
"to",
"Columns",
"but",
"it",
"only",
"searches",
"struct",
"tags",
"and",
"excludes",
"fields",
"not",
"tagged",
"with",
"the",
"db",
"struct",
"tag"
] | 2e129a9c2603efc4380c7b7d318785b4ff6803ab | https://github.com/blockloop/scan/blob/2e129a9c2603efc4380c7b7d318785b4ff6803ab/columns.go#L25-L27 |
132,894 | blockloop/scan | scanner.go | fieldByName | func fieldByName(v reflect.Value, name string, strict bool) reflect.Value {
typ := v.Type()
for i := 0; i < v.NumField(); i++ {
tag, ok := typ.Field(i).Tag.Lookup("db")
if ok && tag == name {
return v.Field(i)
}
}
if strict {
return reflect.ValueOf(nil)
}
return v.FieldByName(strings.Title(name))
} | go | func fieldByName(v reflect.Value, name string, strict bool) reflect.Value {
typ := v.Type()
for i := 0; i < v.NumField(); i++ {
tag, ok := typ.Field(i).Tag.Lookup("db")
if ok && tag == name {
return v.Field(i)
}
}
if strict {
return reflect.ValueOf(nil)
}
return v.FieldByName(strings.Title(name))
} | [
"func",
"fieldByName",
"(",
"v",
"reflect",
".",
"Value",
",",
"name",
"string",
",",
"strict",
"bool",
")",
"reflect",
".",
"Value",
"{",
"typ",
":=",
"v",
".",
"Type",
"(",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"v",
".",
"NumField"... | // fieldByName gets a struct's field by first looking up the db struct tag and falling
// back to the field's name in Title case. | [
"fieldByName",
"gets",
"a",
"struct",
"s",
"field",
"by",
"first",
"looking",
"up",
"the",
"db",
"struct",
"tag",
"and",
"falling",
"back",
"to",
"the",
"field",
"s",
"name",
"in",
"Title",
"case",
"."
] | 2e129a9c2603efc4380c7b7d318785b4ff6803ab | https://github.com/blockloop/scan/blob/2e129a9c2603efc4380c7b7d318785b4ff6803ab/scanner.go#L133-L146 |
132,895 | jaegertracing/jaeger-lib | metrics/tally/metrics.go | Update | func (g *Gauge) Update(value int64) {
g.gauge.Update(float64(value))
} | go | func (g *Gauge) Update(value int64) {
g.gauge.Update(float64(value))
} | [
"func",
"(",
"g",
"*",
"Gauge",
")",
"Update",
"(",
"value",
"int64",
")",
"{",
"g",
".",
"gauge",
".",
"Update",
"(",
"float64",
"(",
"value",
")",
")",
"\n",
"}"
] | // Update the gauge to the value passed in. | [
"Update",
"the",
"gauge",
"to",
"the",
"value",
"passed",
"in",
"."
] | d036253de8f5b698150d81b922486f1e8e7628ec | https://github.com/jaegertracing/jaeger-lib/blob/d036253de8f5b698150d81b922486f1e8e7628ec/metrics/tally/metrics.go#L49-L51 |
132,896 | jaegertracing/jaeger-lib | metrics/keys.go | GetKey | func GetKey(name string, tags map[string]string, tagsSep string, tagKVSep string) string {
keys := make([]string, 0, len(tags))
for k := range tags {
keys = append(keys, k)
}
sort.Strings(keys)
key := name
for _, k := range keys {
key = key + tagsSep + k + tagKVSep + tags[k]
}
return key
} | go | func GetKey(name string, tags map[string]string, tagsSep string, tagKVSep string) string {
keys := make([]string, 0, len(tags))
for k := range tags {
keys = append(keys, k)
}
sort.Strings(keys)
key := name
for _, k := range keys {
key = key + tagsSep + k + tagKVSep + tags[k]
}
return key
} | [
"func",
"GetKey",
"(",
"name",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"tagsSep",
"string",
",",
"tagKVSep",
"string",
")",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"tags",
")... | // GetKey converts name+tags into a single string of the form
// "name|tag1=value1|...|tagN=valueN", where tag names are
// sorted alphabetically. | [
"GetKey",
"converts",
"name",
"+",
"tags",
"into",
"a",
"single",
"string",
"of",
"the",
"form",
"name|tag1",
"=",
"value1|",
"...",
"|tagN",
"=",
"valueN",
"where",
"tag",
"names",
"are",
"sorted",
"alphabetically",
"."
] | d036253de8f5b698150d81b922486f1e8e7628ec | https://github.com/jaegertracing/jaeger-lib/blob/d036253de8f5b698150d81b922486f1e8e7628ec/metrics/keys.go#L24-L35 |
132,897 | jaegertracing/jaeger-lib | metrics/go-kit/factory.go | Wrap | func Wrap(namespace string, f Factory, options ...FactoryOption) metrics.Factory {
factory := &factory{
scope: namespace,
factory: f,
scopeSep: ".",
tagsSep: ".",
tagKVSep: "_",
}
for i := range options {
options[i](factory)
}
return factory
} | go | func Wrap(namespace string, f Factory, options ...FactoryOption) metrics.Factory {
factory := &factory{
scope: namespace,
factory: f,
scopeSep: ".",
tagsSep: ".",
tagKVSep: "_",
}
for i := range options {
options[i](factory)
}
return factory
} | [
"func",
"Wrap",
"(",
"namespace",
"string",
",",
"f",
"Factory",
",",
"options",
"...",
"FactoryOption",
")",
"metrics",
".",
"Factory",
"{",
"factory",
":=",
"&",
"factory",
"{",
"scope",
":",
"namespace",
",",
"factory",
":",
"f",
",",
"scopeSep",
":",... | // Wrap is used to create an adapter from xkit.Factory to metrics.Factory. | [
"Wrap",
"is",
"used",
"to",
"create",
"an",
"adapter",
"from",
"xkit",
".",
"Factory",
"to",
"metrics",
".",
"Factory",
"."
] | d036253de8f5b698150d81b922486f1e8e7628ec | https://github.com/jaegertracing/jaeger-lib/blob/d036253de8f5b698150d81b922486f1e8e7628ec/metrics/go-kit/factory.go#L42-L54 |
132,898 | jaegertracing/jaeger-lib | metrics/go-kit/factory.go | nameAndTagsList | func (f *factory) nameAndTagsList(nom string, tags map[string]string) (name string, tagsList []string) {
mergedTags := f.mergeTags(tags)
name = f.subScope(nom)
tagsList = f.tagsList(mergedTags)
if len(tagsList) == 0 || f.factory.Capabilities().Tagging {
return
}
name = metrics.GetKey(name, mergedTags, f.tagsSep... | go | func (f *factory) nameAndTagsList(nom string, tags map[string]string) (name string, tagsList []string) {
mergedTags := f.mergeTags(tags)
name = f.subScope(nom)
tagsList = f.tagsList(mergedTags)
if len(tagsList) == 0 || f.factory.Capabilities().Tagging {
return
}
name = metrics.GetKey(name, mergedTags, f.tagsSep... | [
"func",
"(",
"f",
"*",
"factory",
")",
"nameAndTagsList",
"(",
"nom",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"name",
"string",
",",
"tagsList",
"[",
"]",
"string",
")",
"{",
"mergedTags",
":=",
"f",
".",
"mergeTags",
"(... | // nameAndTagsList returns a name and tags list for the new metrics.
// The name is a concatenation of nom and the current factory scope.
// The tags list is a flattened list of passed tags merged with factory tags.
// If the underlying factory does not support tags, then the tags are
// transformed into a string and a... | [
"nameAndTagsList",
"returns",
"a",
"name",
"and",
"tags",
"list",
"for",
"the",
"new",
"metrics",
".",
"The",
"name",
"is",
"a",
"concatenation",
"of",
"nom",
"and",
"the",
"current",
"factory",
"scope",
".",
"The",
"tags",
"list",
"is",
"a",
"flattened",
... | d036253de8f5b698150d81b922486f1e8e7628ec | https://github.com/jaegertracing/jaeger-lib/blob/d036253de8f5b698150d81b922486f1e8e7628ec/metrics/go-kit/factory.go#L94-L104 |
132,899 | jaegertracing/jaeger-lib | metrics/adapters/tagless.go | WrapFactoryWithoutTags | func WrapFactoryWithoutTags(f FactoryWithoutTags, options Options) metrics.Factory {
return WrapFactoryWithTags(
&tagless{
Options: defaultOptions(options),
factory: f,
},
options,
)
} | go | func WrapFactoryWithoutTags(f FactoryWithoutTags, options Options) metrics.Factory {
return WrapFactoryWithTags(
&tagless{
Options: defaultOptions(options),
factory: f,
},
options,
)
} | [
"func",
"WrapFactoryWithoutTags",
"(",
"f",
"FactoryWithoutTags",
",",
"options",
"Options",
")",
"metrics",
".",
"Factory",
"{",
"return",
"WrapFactoryWithTags",
"(",
"&",
"tagless",
"{",
"Options",
":",
"defaultOptions",
"(",
"options",
")",
",",
"factory",
":... | // WrapFactoryWithoutTags creates a real metrics.Factory that supports subscopes. | [
"WrapFactoryWithoutTags",
"creates",
"a",
"real",
"metrics",
".",
"Factory",
"that",
"supports",
"subscopes",
"."
] | d036253de8f5b698150d81b922486f1e8e7628ec | https://github.com/jaegertracing/jaeger-lib/blob/d036253de8f5b698150d81b922486f1e8e7628ec/metrics/adapters/tagless.go#L53-L61 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.