id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
800 | turnage/graw | reddit/bot.go | NewBot | func NewBot(c BotConfig) (Bot, error) {
cli, err := newClient(clientConfig{agent: c.Agent, app: c.App})
r := newReaper(
reaperConfig{
client: cli,
parser: newParser(),
hostname: "oauth.reddit.com",
tls: true,
rate: maxOf(c.Rate, time.Second),
},
)
return &bot{
Account: newAccount(r),
Lurker: newLurker(r),
Scanner: newScanner(r),
}, err
} | go | func NewBot(c BotConfig) (Bot, error) {
cli, err := newClient(clientConfig{agent: c.Agent, app: c.App})
r := newReaper(
reaperConfig{
client: cli,
parser: newParser(),
hostname: "oauth.reddit.com",
tls: true,
rate: maxOf(c.Rate, time.Second),
},
)
return &bot{
Account: newAccount(r),
Lurker: newLurker(r),
Scanner: newScanner(r),
}, err
} | [
"func",
"NewBot",
"(",
"c",
"BotConfig",
")",
"(",
"Bot",
",",
"error",
")",
"{",
"cli",
",",
"err",
":=",
"newClient",
"(",
"clientConfig",
"{",
"agent",
":",
"c",
".",
"Agent",
",",
"app",
":",
"c",
".",
"App",
"}",
")",
"\n",
"r",
":=",
"new... | // NewBot returns a logged in handle to the Reddit API. | [
"NewBot",
"returns",
"a",
"logged",
"in",
"handle",
"to",
"the",
"Reddit",
"API",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/bot.go#L37-L53 |
801 | turnage/graw | streams/streams.go | User | func User(
scanner reddit.Scanner,
kill <-chan bool,
errs chan<- error,
user string,
) (
<-chan *reddit.Post,
<-chan *reddit.Comment,
error,
) {
path := "/u/" + user
posts, comments, _, err := streamFromPath(scanner, kill, errs, path)
return posts, comments, err
} | go | func User(
scanner reddit.Scanner,
kill <-chan bool,
errs chan<- error,
user string,
) (
<-chan *reddit.Post,
<-chan *reddit.Comment,
error,
) {
path := "/u/" + user
posts, comments, _, err := streamFromPath(scanner, kill, errs, path)
return posts, comments, err
} | [
"func",
"User",
"(",
"scanner",
"reddit",
".",
"Scanner",
",",
"kill",
"<-",
"chan",
"bool",
",",
"errs",
"chan",
"<-",
"error",
",",
"user",
"string",
",",
")",
"(",
"<-",
"chan",
"*",
"reddit",
".",
"Post",
",",
"<-",
"chan",
"*",
"reddit",
".",
... | // User returns a stream of new posts and comments made by a user. Each user
// stream consumes one interval of the handle. | [
"User",
"returns",
"a",
"stream",
"of",
"new",
"posts",
"and",
"comments",
"made",
"by",
"a",
"user",
".",
"Each",
"user",
"stream",
"consumes",
"one",
"interval",
"of",
"the",
"handle",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/streams/streams.go#L93-L106 |
802 | turnage/graw | streams/streams.go | Messages | func Messages(
bot reddit.Bot,
kill <-chan bool,
errs chan<- error,
) (
<-chan *reddit.Message,
error,
) {
onlyMessages := make(chan *reddit.Message)
messages, err := inboxStream(bot, kill, errs, "inbox")
go func() {
for m := range messages {
if !m.WasComment {
onlyMessages <- m
}
}
}()
return onlyMessages, err
} | go | func Messages(
bot reddit.Bot,
kill <-chan bool,
errs chan<- error,
) (
<-chan *reddit.Message,
error,
) {
onlyMessages := make(chan *reddit.Message)
messages, err := inboxStream(bot, kill, errs, "inbox")
go func() {
for m := range messages {
if !m.WasComment {
onlyMessages <- m
}
}
}()
return onlyMessages, err
} | [
"func",
"Messages",
"(",
"bot",
"reddit",
".",
"Bot",
",",
"kill",
"<-",
"chan",
"bool",
",",
"errs",
"chan",
"<-",
"error",
",",
")",
"(",
"<-",
"chan",
"*",
"reddit",
".",
"Message",
",",
"error",
",",
")",
"{",
"onlyMessages",
":=",
"make",
"(",... | // Messages returns a stream of messages sent to the bot's inbox. It consumes
// one interval of the handle. | [
"Messages",
"returns",
"a",
"stream",
"of",
"messages",
"sent",
"to",
"the",
"bot",
"s",
"inbox",
".",
"It",
"consumes",
"one",
"interval",
"of",
"the",
"handle",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/streams/streams.go#L151-L171 |
803 | turnage/graw | reddit/client.go | newClient | func newClient(c clientConfig) (client, error) {
if c.app.tokenURL == "" {
c.app.tokenURL = tokenURL
}
if c.app.unauthenticated() {
return &baseClient{clientWithAgent(c.agent)}, nil
}
if err := c.app.validateAuth(); err != nil {
return nil, err
}
return newAppClient(c)
} | go | func newClient(c clientConfig) (client, error) {
if c.app.tokenURL == "" {
c.app.tokenURL = tokenURL
}
if c.app.unauthenticated() {
return &baseClient{clientWithAgent(c.agent)}, nil
}
if err := c.app.validateAuth(); err != nil {
return nil, err
}
return newAppClient(c)
} | [
"func",
"newClient",
"(",
"c",
"clientConfig",
")",
"(",
"client",
",",
"error",
")",
"{",
"if",
"c",
".",
"app",
".",
"tokenURL",
"==",
"\"",
"\"",
"{",
"c",
".",
"app",
".",
"tokenURL",
"=",
"tokenURL",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"app",... | // newClient returns a new client using the given user to make requests. | [
"newClient",
"returns",
"a",
"new",
"client",
"using",
"the",
"given",
"user",
"to",
"make",
"requests",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/client.go#L66-L80 |
804 | turnage/graw | reddit/parse.go | parse | func (p *parserImpl) parse(
blob json.RawMessage,
) ([]*Comment, []*Post, []*Message, error) {
comments, posts, msgs, listingErr := parseRawListing(blob)
if listingErr == nil {
return comments, posts, msgs, nil
}
post, threadErr := parseThread(blob)
if threadErr == nil {
return nil, []*Post{post}, nil, nil
}
return nil, nil, nil, fmt.Errorf(
"failed to parse as listing [%v] or thread [%v]",
listingErr, threadErr,
)
} | go | func (p *parserImpl) parse(
blob json.RawMessage,
) ([]*Comment, []*Post, []*Message, error) {
comments, posts, msgs, listingErr := parseRawListing(blob)
if listingErr == nil {
return comments, posts, msgs, nil
}
post, threadErr := parseThread(blob)
if threadErr == nil {
return nil, []*Post{post}, nil, nil
}
return nil, nil, nil, fmt.Errorf(
"failed to parse as listing [%v] or thread [%v]",
listingErr, threadErr,
)
} | [
"func",
"(",
"p",
"*",
"parserImpl",
")",
"parse",
"(",
"blob",
"json",
".",
"RawMessage",
",",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"[",
"]",
"*",
"Post",
",",
"[",
"]",
"*",
"Message",
",",
"error",
")",
"{",
"comments",
",",
"posts",
","... | // parse parses any Reddit response and provides the elements in it. | [
"parse",
"parses",
"any",
"Reddit",
"response",
"and",
"provides",
"the",
"elements",
"in",
"it",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/parse.go#L51-L68 |
805 | turnage/graw | reddit/parse.go | parseRawListing | func parseRawListing(
blob json.RawMessage,
) ([]*Comment, []*Post, []*Message, error) {
var activityListing thing
if err := json.Unmarshal(blob, &activityListing); err != nil {
return nil, nil, nil, err
}
return parseListing(&activityListing)
} | go | func parseRawListing(
blob json.RawMessage,
) ([]*Comment, []*Post, []*Message, error) {
var activityListing thing
if err := json.Unmarshal(blob, &activityListing); err != nil {
return nil, nil, nil, err
}
return parseListing(&activityListing)
} | [
"func",
"parseRawListing",
"(",
"blob",
"json",
".",
"RawMessage",
",",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"[",
"]",
"*",
"Post",
",",
"[",
"]",
"*",
"Message",
",",
"error",
")",
"{",
"var",
"activityListing",
"thing",
"\n",
"if",
"err",
":=... | // parseRawListing parses a listing json blob and returns the elements in it. | [
"parseRawListing",
"parses",
"a",
"listing",
"json",
"blob",
"and",
"returns",
"the",
"elements",
"in",
"it",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/parse.go#L71-L80 |
806 | turnage/graw | reddit/parse.go | parseThread | func parseThread(blob json.RawMessage) (*Post, error) {
var listings [2]thing
if err := json.Unmarshal(blob, &listings); err != nil {
return nil, err
}
_, posts, _, err := parseListing(&listings[0])
if err != nil {
return nil, err
}
if len(posts) != 1 {
return nil, fmt.Errorf("expected 1 post; found %d", len(posts))
}
comments, _, _, err := parseListing(&listings[1])
if err != nil {
return nil, err
}
posts[0].Replies = comments
return posts[0], nil
} | go | func parseThread(blob json.RawMessage) (*Post, error) {
var listings [2]thing
if err := json.Unmarshal(blob, &listings); err != nil {
return nil, err
}
_, posts, _, err := parseListing(&listings[0])
if err != nil {
return nil, err
}
if len(posts) != 1 {
return nil, fmt.Errorf("expected 1 post; found %d", len(posts))
}
comments, _, _, err := parseListing(&listings[1])
if err != nil {
return nil, err
}
posts[0].Replies = comments
return posts[0], nil
} | [
"func",
"parseThread",
"(",
"blob",
"json",
".",
"RawMessage",
")",
"(",
"*",
"Post",
",",
"error",
")",
"{",
"var",
"listings",
"[",
"2",
"]",
"thing",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"blob",
",",
"&",
"listings",
")",
";",... | // parseThread parses a post from a thread json blob returned by Reddit.
//
// Reddit structures this as two things in an array, the first thing being a
// listing with only the post and the second thing being a listing of comments. | [
"parseThread",
"parses",
"a",
"post",
"from",
"a",
"thread",
"json",
"blob",
"returned",
"by",
"Reddit",
".",
"Reddit",
"structures",
"this",
"as",
"two",
"things",
"in",
"an",
"array",
"the",
"first",
"thing",
"being",
"a",
"listing",
"with",
"only",
"the... | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/parse.go#L86-L108 |
807 | turnage/graw | reddit/parse.go | parseListing | func parseListing(t *thing) ([]*Comment, []*Post, []*Message, error) {
if t.Kind != listingKind {
return nil, nil, nil, fmt.Errorf("thing is not listing")
}
l := &listing{}
if err := mapstructure.Decode(t.Data, l); err != nil {
return nil, nil, nil, mapDecodeError(err, t.Data)
}
comments := []*Comment{}
posts := []*Post{}
msgs := []*Message{}
err := error(nil)
for _, c := range l.Children {
if err != nil {
break
}
var comment *Comment
var post *Post
var msg *Message
// Reddit sets the "Kind" field of comments in the inbox, which
// have only Message and not Comment fields, to commentKind. The
// give away in this case is that comments in message form have
// a field called "was_comment". Reddit does this because they
// hate programmers.
if c.Kind == messageKind || c.Data["was_comment"] != nil {
msg, err = parseMessage(&c)
msgs = append(msgs, msg)
} else if c.Kind == commentKind {
comment, err = parseComment(&c)
comments = append(comments, comment)
} else if c.Kind == postKind {
post, err = parsePost(&c)
posts = append(posts, post)
}
}
return comments, posts, msgs, err
} | go | func parseListing(t *thing) ([]*Comment, []*Post, []*Message, error) {
if t.Kind != listingKind {
return nil, nil, nil, fmt.Errorf("thing is not listing")
}
l := &listing{}
if err := mapstructure.Decode(t.Data, l); err != nil {
return nil, nil, nil, mapDecodeError(err, t.Data)
}
comments := []*Comment{}
posts := []*Post{}
msgs := []*Message{}
err := error(nil)
for _, c := range l.Children {
if err != nil {
break
}
var comment *Comment
var post *Post
var msg *Message
// Reddit sets the "Kind" field of comments in the inbox, which
// have only Message and not Comment fields, to commentKind. The
// give away in this case is that comments in message form have
// a field called "was_comment". Reddit does this because they
// hate programmers.
if c.Kind == messageKind || c.Data["was_comment"] != nil {
msg, err = parseMessage(&c)
msgs = append(msgs, msg)
} else if c.Kind == commentKind {
comment, err = parseComment(&c)
comments = append(comments, comment)
} else if c.Kind == postKind {
post, err = parsePost(&c)
posts = append(posts, post)
}
}
return comments, posts, msgs, err
} | [
"func",
"parseListing",
"(",
"t",
"*",
"thing",
")",
"(",
"[",
"]",
"*",
"Comment",
",",
"[",
"]",
"*",
"Post",
",",
"[",
"]",
"*",
"Message",
",",
"error",
")",
"{",
"if",
"t",
".",
"Kind",
"!=",
"listingKind",
"{",
"return",
"nil",
",",
"nil"... | // parseListing parses a Reddit listing type and returns the elements inside it. | [
"parseListing",
"parses",
"a",
"Reddit",
"listing",
"type",
"and",
"returns",
"the",
"elements",
"inside",
"it",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/parse.go#L111-L153 |
808 | turnage/graw | reddit/parse.go | parseComment | func parseComment(t *thing) (*Comment, error) {
// Reddit makes the replies field a string if it is empty, just to make
// it harder for programmers who like static type systems.
value, present := t.Data["replies"]
if present {
if str, ok := value.(string); ok && str == "" {
delete(t.Data, "replies")
}
}
c := &comment{}
if err := mapstructure.Decode(t.Data, c); err != nil {
return nil, mapDecodeError(err, t.Data)
}
var err error
if c.Replies.Kind == listingKind {
c.Comment.Replies, _, _, err = parseListing(&c.Replies)
}
c.Comment.Deleted = c.Comment.Body == deletedKey
return &c.Comment, err
} | go | func parseComment(t *thing) (*Comment, error) {
// Reddit makes the replies field a string if it is empty, just to make
// it harder for programmers who like static type systems.
value, present := t.Data["replies"]
if present {
if str, ok := value.(string); ok && str == "" {
delete(t.Data, "replies")
}
}
c := &comment{}
if err := mapstructure.Decode(t.Data, c); err != nil {
return nil, mapDecodeError(err, t.Data)
}
var err error
if c.Replies.Kind == listingKind {
c.Comment.Replies, _, _, err = parseListing(&c.Replies)
}
c.Comment.Deleted = c.Comment.Body == deletedKey
return &c.Comment, err
} | [
"func",
"parseComment",
"(",
"t",
"*",
"thing",
")",
"(",
"*",
"Comment",
",",
"error",
")",
"{",
"// Reddit makes the replies field a string if it is empty, just to make",
"// it harder for programmers who like static type systems.",
"value",
",",
"present",
":=",
"t",
"."... | // parseComment parses a comment into the user facing Comment struct. | [
"parseComment",
"parses",
"a",
"comment",
"into",
"the",
"user",
"facing",
"Comment",
"struct",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/parse.go#L156-L178 |
809 | turnage/graw | reddit/parse.go | parsePost | func parsePost(t *thing) (*Post, error) {
p := &Post{}
if err := mapstructure.Decode(t.Data, p); err != nil {
return nil, mapDecodeError(err, t.Data)
}
p.Deleted = p.SelfText == deletedKey
return p, nil
} | go | func parsePost(t *thing) (*Post, error) {
p := &Post{}
if err := mapstructure.Decode(t.Data, p); err != nil {
return nil, mapDecodeError(err, t.Data)
}
p.Deleted = p.SelfText == deletedKey
return p, nil
} | [
"func",
"parsePost",
"(",
"t",
"*",
"thing",
")",
"(",
"*",
"Post",
",",
"error",
")",
"{",
"p",
":=",
"&",
"Post",
"{",
"}",
"\n",
"if",
"err",
":=",
"mapstructure",
".",
"Decode",
"(",
"t",
".",
"Data",
",",
"p",
")",
";",
"err",
"!=",
"nil... | // parsePost parses a post into the user facing Post struct. | [
"parsePost",
"parses",
"a",
"post",
"into",
"the",
"user",
"facing",
"Post",
"struct",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/parse.go#L181-L189 |
810 | turnage/graw | reddit/parse.go | parseMessage | func parseMessage(t *thing) (*Message, error) {
m := &Message{}
return m, mapstructure.Decode(t.Data, m)
} | go | func parseMessage(t *thing) (*Message, error) {
m := &Message{}
return m, mapstructure.Decode(t.Data, m)
} | [
"func",
"parseMessage",
"(",
"t",
"*",
"thing",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"m",
":=",
"&",
"Message",
"{",
"}",
"\n",
"return",
"m",
",",
"mapstructure",
".",
"Decode",
"(",
"t",
".",
"Data",
",",
"m",
")",
"\n",
"}"
] | // parseMessage parses a message into the user facing Message struct. | [
"parseMessage",
"parses",
"a",
"message",
"into",
"the",
"user",
"facing",
"Message",
"struct",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/parse.go#L192-L195 |
811 | turnage/graw | reddit/minduration.go | maxOf | func maxOf(a, b time.Duration) time.Duration {
// lol no ternary statements
if a > b {
return a
}
return b
} | go | func maxOf(a, b time.Duration) time.Duration {
// lol no ternary statements
if a > b {
return a
}
return b
} | [
"func",
"maxOf",
"(",
"a",
",",
"b",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"// lol no ternary statements",
"if",
"a",
">",
"b",
"{",
"return",
"a",
"\n",
"}",
"\n\n",
"return",
"b",
"\n",
"}"
] | // lol no generics | [
"lol",
"no",
"generics"
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/minduration.go#L8-L15 |
812 | turnage/graw | reddit/agentforwarder.go | RoundTrip | func (a *agentForwarder) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Add("User-Agent", a.agent)
return a.Transport.RoundTrip(r)
} | go | func (a *agentForwarder) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Add("User-Agent", a.agent)
return a.Transport.RoundTrip(r)
} | [
"func",
"(",
"a",
"*",
"agentForwarder",
")",
"RoundTrip",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"r",
".",
"Header",
".",
"Add",
"(",
"\"",
"\"",
",",
"a",
".",
"agent",
")",
"\n"... | // RoundTrip sets a predefined agent in the request and then forwards it to the
// default RountTrip implementation. | [
"RoundTrip",
"sets",
"a",
"predefined",
"agent",
"in",
"the",
"request",
"and",
"then",
"forwards",
"it",
"to",
"the",
"default",
"RountTrip",
"implementation",
"."
] | 3295929039f653fa7028de98b47e5abf51413322 | https://github.com/turnage/graw/blob/3295929039f653fa7028de98b47e5abf51413322/reddit/agentforwarder.go#L15-L18 |
813 | rsc/letsencrypt | lets.go | ServeHTTPS | func (m *Manager) ServeHTTPS() error {
srv := &http.Server{
Addr: ":https",
TLSConfig: &tls.Config{
GetCertificate: m.GetCertificate,
},
}
return srv.ListenAndServeTLS("", "")
} | go | func (m *Manager) ServeHTTPS() error {
srv := &http.Server{
Addr: ":https",
TLSConfig: &tls.Config{
GetCertificate: m.GetCertificate,
},
}
return srv.ListenAndServeTLS("", "")
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ServeHTTPS",
"(",
")",
"error",
"{",
"srv",
":=",
"&",
"http",
".",
"Server",
"{",
"Addr",
":",
"\"",
"\"",
",",
"TLSConfig",
":",
"&",
"tls",
".",
"Config",
"{",
"GetCertificate",
":",
"m",
".",
"GetCertific... | // ServeHTTPS runs an HTTPS web server using TLS certificates obtained by the manager.
// The HTTPS server obtains TLS certificates as needed and responds to requests
// by invoking http.DefaultServeMux.
// ServeHTTPS does not return unitil the HTTPS server fails to start or else stops.
// Either way, ServeHTTPS can only return a non-nil error, never nil. | [
"ServeHTTPS",
"runs",
"an",
"HTTPS",
"web",
"server",
"using",
"TLS",
"certificates",
"obtained",
"by",
"the",
"manager",
".",
"The",
"HTTPS",
"server",
"obtains",
"TLS",
"certificates",
"as",
"needed",
"and",
"responds",
"to",
"requests",
"by",
"invoking",
"h... | 800d85d42bc784015c7189f6fad2d342ad65dd99 | https://github.com/rsc/letsencrypt/blob/800d85d42bc784015c7189f6fad2d342ad65dd99/lets.go#L239-L247 |
814 | rsc/letsencrypt | lets.go | Registered | func (m *Manager) Registered() bool {
m.init()
m.mu.Lock()
defer m.mu.Unlock()
return m.registered()
} | go | func (m *Manager) Registered() bool {
m.init()
m.mu.Lock()
defer m.mu.Unlock()
return m.registered()
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Registered",
"(",
")",
"bool",
"{",
"m",
".",
"init",
"(",
")",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"m",
".",
"registered... | // Registered reports whether the manager has registered with letsencrypt.org yet. | [
"Registered",
"reports",
"whether",
"the",
"manager",
"has",
"registered",
"with",
"letsencrypt",
".",
"org",
"yet",
"."
] | 800d85d42bc784015c7189f6fad2d342ad65dd99 | https://github.com/rsc/letsencrypt/blob/800d85d42bc784015c7189f6fad2d342ad65dd99/lets.go#L373-L378 |
815 | rsc/letsencrypt | lets.go | Marshal | func (m *Manager) Marshal() string {
m.init()
m.mu.Lock()
js, err := json.MarshalIndent(&m.state, "", "\t")
m.mu.Unlock()
if err != nil {
panic("unexpected json.Marshal failure")
}
return string(js)
} | go | func (m *Manager) Marshal() string {
m.init()
m.mu.Lock()
js, err := json.MarshalIndent(&m.state, "", "\t")
m.mu.Unlock()
if err != nil {
panic("unexpected json.Marshal failure")
}
return string(js)
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Marshal",
"(",
")",
"string",
"{",
"m",
".",
"init",
"(",
")",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"js",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"&",
"m",
".",
"state",
",",
... | // Marshal returns an encoding of the manager's state,
// suitable for writing to disk and reloading by calling Unmarshal.
// The state includes registration status, the configured host list
// from SetHosts, and all known certificates, including their private
// cryptographic keys.
// Consequently, the state should be kept private. | [
"Marshal",
"returns",
"an",
"encoding",
"of",
"the",
"manager",
"s",
"state",
"suitable",
"for",
"writing",
"to",
"disk",
"and",
"reloading",
"by",
"calling",
"Unmarshal",
".",
"The",
"state",
"includes",
"registration",
"status",
"the",
"configured",
"host",
... | 800d85d42bc784015c7189f6fad2d342ad65dd99 | https://github.com/rsc/letsencrypt/blob/800d85d42bc784015c7189f6fad2d342ad65dd99/lets.go#L453-L462 |
816 | rsc/letsencrypt | lets.go | SetHosts | func (m *Manager) SetHosts(hosts []string) {
m.init()
m.mu.Lock()
m.state.Hosts = append(m.state.Hosts[:0], hosts...)
m.mu.Unlock()
m.updated()
} | go | func (m *Manager) SetHosts(hosts []string) {
m.init()
m.mu.Lock()
m.state.Hosts = append(m.state.Hosts[:0], hosts...)
m.mu.Unlock()
m.updated()
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SetHosts",
"(",
"hosts",
"[",
"]",
"string",
")",
"{",
"m",
".",
"init",
"(",
")",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"state",
".",
"Hosts",
"=",
"append",
"(",
"m",
".",
"st... | // SetHosts sets the manager's list of known host names.
// If the list is non-nil, the manager will only ever attempt to acquire
// certificates for host names on the list.
// If the list is nil, the manager does not restrict the hosts it will
// ask for certificates for. | [
"SetHosts",
"sets",
"the",
"manager",
"s",
"list",
"of",
"known",
"host",
"names",
".",
"If",
"the",
"list",
"is",
"non",
"-",
"nil",
"the",
"manager",
"will",
"only",
"ever",
"attempt",
"to",
"acquire",
"certificates",
"for",
"host",
"names",
"on",
"the... | 800d85d42bc784015c7189f6fad2d342ad65dd99 | https://github.com/rsc/letsencrypt/blob/800d85d42bc784015c7189f6fad2d342ad65dd99/lets.go#L499-L505 |
817 | rsc/letsencrypt | lets.go | GetCertificate | func (m *Manager) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
m.init()
host := clientHello.ServerName
if debug {
log.Printf("GetCertificate %s", host)
}
if strings.HasSuffix(host, ".acme.invalid") {
m.mu.Lock()
cert := m.certTokens[host]
m.mu.Unlock()
if cert == nil {
return nil, fmt.Errorf("unknown host")
}
return cert, nil
}
return m.Cert(host)
} | go | func (m *Manager) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
m.init()
host := clientHello.ServerName
if debug {
log.Printf("GetCertificate %s", host)
}
if strings.HasSuffix(host, ".acme.invalid") {
m.mu.Lock()
cert := m.certTokens[host]
m.mu.Unlock()
if cert == nil {
return nil, fmt.Errorf("unknown host")
}
return cert, nil
}
return m.Cert(host)
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetCertificate",
"(",
"clientHello",
"*",
"tls",
".",
"ClientHelloInfo",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"m",
".",
"init",
"(",
")",
"\n\n",
"host",
":=",
"clientHello",
".",
"... | // GetCertificate can be placed a tls.Config's GetCertificate field to make
// the TLS server use Let's Encrypt certificates.
// Each time a client connects to the TLS server expecting a new host name,
// the TLS server's call to GetCertificate will trigger an exchange with the
// Let's Encrypt servers to obtain that certificate, subject to the manager rate limits.
//
// As noted in the Manager's documentation comment,
// to obtain a certificate for a given host name, that name
// must resolve to a computer running a TLS server on port 443
// that obtains TLS SNI certificates by calling m.GetCertificate.
// In the standard usage, then, installing m.GetCertificate in the tls.Config
// both automatically provisions the TLS certificates needed for
// ordinary HTTPS service and answers the challenges from LetsEncrypt.org. | [
"GetCertificate",
"can",
"be",
"placed",
"a",
"tls",
".",
"Config",
"s",
"GetCertificate",
"field",
"to",
"make",
"the",
"TLS",
"server",
"use",
"Let",
"s",
"Encrypt",
"certificates",
".",
"Each",
"time",
"a",
"client",
"connects",
"to",
"the",
"TLS",
"ser... | 800d85d42bc784015c7189f6fad2d342ad65dd99 | https://github.com/rsc/letsencrypt/blob/800d85d42bc784015c7189f6fad2d342ad65dd99/lets.go#L520-L540 |
818 | rsc/letsencrypt | lets.go | Cert | func (m *Manager) Cert(host string) (*tls.Certificate, error) {
host = strings.ToLower(host)
if debug {
log.Printf("Cert %s", host)
}
m.init()
m.mu.Lock()
if !m.registered() {
m.register("", nil)
}
ok := false
if m.state.Hosts == nil {
ok = true
} else {
for _, h := range m.state.Hosts {
if host == h {
ok = true
break
}
}
}
if !ok {
m.mu.Unlock()
return nil, fmt.Errorf("unknown host")
}
// Otherwise look in our cert cache.
entry, ok := m.certCache[host]
if !ok {
r := m.rateLimit.Reserve()
ok := r.OK()
if ok {
ok = m.newHostLimit.Allow()
if !ok {
r.Cancel()
}
}
if !ok {
m.mu.Unlock()
return nil, fmt.Errorf("rate limited")
}
entry = &cacheEntry{host: host, m: m}
m.certCache[host] = entry
}
m.mu.Unlock()
entry.mu.Lock()
defer entry.mu.Unlock()
entry.init()
if entry.err != nil {
return nil, entry.err
}
return entry.cert, nil
} | go | func (m *Manager) Cert(host string) (*tls.Certificate, error) {
host = strings.ToLower(host)
if debug {
log.Printf("Cert %s", host)
}
m.init()
m.mu.Lock()
if !m.registered() {
m.register("", nil)
}
ok := false
if m.state.Hosts == nil {
ok = true
} else {
for _, h := range m.state.Hosts {
if host == h {
ok = true
break
}
}
}
if !ok {
m.mu.Unlock()
return nil, fmt.Errorf("unknown host")
}
// Otherwise look in our cert cache.
entry, ok := m.certCache[host]
if !ok {
r := m.rateLimit.Reserve()
ok := r.OK()
if ok {
ok = m.newHostLimit.Allow()
if !ok {
r.Cancel()
}
}
if !ok {
m.mu.Unlock()
return nil, fmt.Errorf("rate limited")
}
entry = &cacheEntry{host: host, m: m}
m.certCache[host] = entry
}
m.mu.Unlock()
entry.mu.Lock()
defer entry.mu.Unlock()
entry.init()
if entry.err != nil {
return nil, entry.err
}
return entry.cert, nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Cert",
"(",
"host",
"string",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"host",
"=",
"strings",
".",
"ToLower",
"(",
"host",
")",
"\n",
"if",
"debug",
"{",
"log",
".",
"Printf",
"(",... | // Cert returns the certificate for the given host name, obtaining a new one if necessary.
//
// As noted in the documentation for Manager and for the GetCertificate method,
// obtaining a certificate requires that m.GetCertificate be associated with host.
// In most servers, simply starting a TLS server with a configuration referring
// to m.GetCertificate is sufficient, and Cert need not be called.
//
// The main use of Cert is to force the manager to obtain a certificate
// for a particular host name ahead of time. | [
"Cert",
"returns",
"the",
"certificate",
"for",
"the",
"given",
"host",
"name",
"obtaining",
"a",
"new",
"one",
"if",
"necessary",
".",
"As",
"noted",
"in",
"the",
"documentation",
"for",
"Manager",
"and",
"for",
"the",
"GetCertificate",
"method",
"obtaining",... | 800d85d42bc784015c7189f6fad2d342ad65dd99 | https://github.com/rsc/letsencrypt/blob/800d85d42bc784015c7189f6fad2d342ad65dd99/lets.go#L551-L606 |
819 | gosuri/uitable | util/strutil/strutil.go | Join | func Join(list []string, delim string) string {
var buf bytes.Buffer
for i := 0; i < len(list)-1; i++ {
buf.WriteString(list[i] + delim)
}
buf.WriteString(list[len(list)-1])
return buf.String()
} | go | func Join(list []string, delim string) string {
var buf bytes.Buffer
for i := 0; i < len(list)-1; i++ {
buf.WriteString(list[i] + delim)
}
buf.WriteString(list[len(list)-1])
return buf.String()
} | [
"func",
"Join",
"(",
"list",
"[",
"]",
"string",
",",
"delim",
"string",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"list",
")",
"-",
"1",
";",
"i",
"++",
"{",
"buf",
".",... | // Join joins the list of the string with the delim provided | [
"Join",
"joins",
"the",
"list",
"of",
"the",
"string",
"with",
"the",
"delim",
"provided"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/util/strutil/strutil.go#L69-L76 |
820 | gosuri/uitable | table.go | New | func New() *Table {
return &Table{
Separator: Separator,
mtx: new(sync.RWMutex),
rightAlign: map[int]bool{},
}
} | go | func New() *Table {
return &Table{
Separator: Separator,
mtx: new(sync.RWMutex),
rightAlign: map[int]bool{},
}
} | [
"func",
"New",
"(",
")",
"*",
"Table",
"{",
"return",
"&",
"Table",
"{",
"Separator",
":",
"Separator",
",",
"mtx",
":",
"new",
"(",
"sync",
".",
"RWMutex",
")",
",",
"rightAlign",
":",
"map",
"[",
"int",
"]",
"bool",
"{",
"}",
",",
"}",
"\n",
... | // New returns a new Table with default values | [
"New",
"returns",
"a",
"new",
"Table",
"with",
"default",
"values"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/table.go#L36-L42 |
821 | gosuri/uitable | table.go | AddRow | func (t *Table) AddRow(data ...interface{}) *Table {
t.mtx.Lock()
defer t.mtx.Unlock()
r := NewRow(data...)
t.Rows = append(t.Rows, r)
return t
} | go | func (t *Table) AddRow(data ...interface{}) *Table {
t.mtx.Lock()
defer t.mtx.Unlock()
r := NewRow(data...)
t.Rows = append(t.Rows, r)
return t
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"AddRow",
"(",
"data",
"...",
"interface",
"{",
"}",
")",
"*",
"Table",
"{",
"t",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"r",
":=",
"NewRow",
"(",... | // AddRow adds a new row to the table | [
"AddRow",
"adds",
"a",
"new",
"row",
"to",
"the",
"table"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/table.go#L45-L51 |
822 | gosuri/uitable | table.go | String | func (t *Table) String() string {
t.mtx.RLock()
defer t.mtx.RUnlock()
if len(t.Rows) == 0 {
return ""
}
// determine the width for each column (cell in a row)
var colwidths []uint
for _, row := range t.Rows {
for i, cell := range row.Cells {
// resize colwidth array
if i+1 > len(colwidths) {
colwidths = append(colwidths, 0)
}
cellwidth := cell.LineWidth()
if t.MaxColWidth != 0 && cellwidth > t.MaxColWidth {
cellwidth = t.MaxColWidth
}
if cellwidth > colwidths[i] {
colwidths[i] = cellwidth
}
}
}
var lines []string
for _, row := range t.Rows {
row.Separator = t.Separator
for i, cell := range row.Cells {
cell.Width = colwidths[i]
cell.Wrap = t.Wrap
cell.RightAlign = t.rightAlign[i]
}
lines = append(lines, row.String())
}
return strutil.Join(lines, "\n")
} | go | func (t *Table) String() string {
t.mtx.RLock()
defer t.mtx.RUnlock()
if len(t.Rows) == 0 {
return ""
}
// determine the width for each column (cell in a row)
var colwidths []uint
for _, row := range t.Rows {
for i, cell := range row.Cells {
// resize colwidth array
if i+1 > len(colwidths) {
colwidths = append(colwidths, 0)
}
cellwidth := cell.LineWidth()
if t.MaxColWidth != 0 && cellwidth > t.MaxColWidth {
cellwidth = t.MaxColWidth
}
if cellwidth > colwidths[i] {
colwidths[i] = cellwidth
}
}
}
var lines []string
for _, row := range t.Rows {
row.Separator = t.Separator
for i, cell := range row.Cells {
cell.Width = colwidths[i]
cell.Wrap = t.Wrap
cell.RightAlign = t.rightAlign[i]
}
lines = append(lines, row.String())
}
return strutil.Join(lines, "\n")
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"String",
"(",
")",
"string",
"{",
"t",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"t",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"len",
"(",
"t",
".",
"Rows",
")",
"==",
"0",
"{",
"ret... | // String returns the string value of table | [
"String",
"returns",
"the",
"string",
"value",
"of",
"table"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/table.go#L65-L103 |
823 | gosuri/uitable | table.go | NewRow | func NewRow(data ...interface{}) *Row {
r := &Row{Cells: make([]*Cell, len(data))}
for i, d := range data {
r.Cells[i] = &Cell{Data: d}
}
return r
} | go | func NewRow(data ...interface{}) *Row {
r := &Row{Cells: make([]*Cell, len(data))}
for i, d := range data {
r.Cells[i] = &Cell{Data: d}
}
return r
} | [
"func",
"NewRow",
"(",
"data",
"...",
"interface",
"{",
"}",
")",
"*",
"Row",
"{",
"r",
":=",
"&",
"Row",
"{",
"Cells",
":",
"make",
"(",
"[",
"]",
"*",
"Cell",
",",
"len",
"(",
"data",
")",
")",
"}",
"\n",
"for",
"i",
",",
"d",
":=",
"rang... | // NewRow returns a new Row and adds the data to the row | [
"NewRow",
"returns",
"a",
"new",
"Row",
"and",
"adds",
"the",
"data",
"to",
"the",
"row"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/table.go#L115-L121 |
824 | gosuri/uitable | table.go | String | func (r *Row) String() string {
// get the max number of lines for each cell
var lc int // line count
for _, cell := range r.Cells {
if clc := len(strings.Split(cell.String(), "\n")); clc > lc {
lc = clc
}
}
// allocate a two-dimentional array of cells for each line and add size them
cells := make([][]*Cell, lc)
for x := 0; x < lc; x++ {
cells[x] = make([]*Cell, len(r.Cells))
for y := 0; y < len(r.Cells); y++ {
cells[x][y] = &Cell{Width: r.Cells[y].Width}
}
}
// insert each line in a cell as new cell in the cells array
for y, cell := range r.Cells {
lines := strings.Split(cell.String(), "\n")
for x, line := range lines {
cells[x][y].Data = line
}
}
// format each line
lines := make([]string, lc)
for x := range lines {
line := make([]string, len(cells[x]))
for y := range cells[x] {
line[y] = cells[x][y].String()
}
lines[x] = strutil.Join(line, r.Separator)
}
return strutil.Join(lines, "\n")
} | go | func (r *Row) String() string {
// get the max number of lines for each cell
var lc int // line count
for _, cell := range r.Cells {
if clc := len(strings.Split(cell.String(), "\n")); clc > lc {
lc = clc
}
}
// allocate a two-dimentional array of cells for each line and add size them
cells := make([][]*Cell, lc)
for x := 0; x < lc; x++ {
cells[x] = make([]*Cell, len(r.Cells))
for y := 0; y < len(r.Cells); y++ {
cells[x][y] = &Cell{Width: r.Cells[y].Width}
}
}
// insert each line in a cell as new cell in the cells array
for y, cell := range r.Cells {
lines := strings.Split(cell.String(), "\n")
for x, line := range lines {
cells[x][y].Data = line
}
}
// format each line
lines := make([]string, lc)
for x := range lines {
line := make([]string, len(cells[x]))
for y := range cells[x] {
line[y] = cells[x][y].String()
}
lines[x] = strutil.Join(line, r.Separator)
}
return strutil.Join(lines, "\n")
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"String",
"(",
")",
"string",
"{",
"// get the max number of lines for each cell",
"var",
"lc",
"int",
"// line count",
"\n",
"for",
"_",
",",
"cell",
":=",
"range",
"r",
".",
"Cells",
"{",
"if",
"clc",
":=",
"len",
"("... | // String returns the string representation of the row | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"the",
"row"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/table.go#L124-L160 |
825 | gosuri/uitable | table.go | LineWidth | func (c *Cell) LineWidth() uint {
width := 0
for _, s := range strings.Split(c.String(), "\n") {
w := runewidth.StringWidth(s)
if w > width {
width = w
}
}
return uint(width)
} | go | func (c *Cell) LineWidth() uint {
width := 0
for _, s := range strings.Split(c.String(), "\n") {
w := runewidth.StringWidth(s)
if w > width {
width = w
}
}
return uint(width)
} | [
"func",
"(",
"c",
"*",
"Cell",
")",
"LineWidth",
"(",
")",
"uint",
"{",
"width",
":=",
"0",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"strings",
".",
"Split",
"(",
"c",
".",
"String",
"(",
")",
",",
"\"",
"\\n",
"\"",
")",
"{",
"w",
":=",
... | // LineWidth returns the max width of all the lines in a cell | [
"LineWidth",
"returns",
"the",
"max",
"width",
"of",
"all",
"the",
"lines",
"in",
"a",
"cell"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/table.go#L178-L187 |
826 | gosuri/uitable | table.go | String | func (c *Cell) String() string {
if c.Data == nil {
return strutil.PadLeft(" ", int(c.Width), ' ')
}
s := fmt.Sprintf("%v", c.Data)
if c.Width > 0 {
if c.Wrap && uint(len(s)) > c.Width {
return wordwrap.WrapString(s, c.Width)
} else {
return strutil.Resize(s, c.Width, c.RightAlign)
}
}
return s
} | go | func (c *Cell) String() string {
if c.Data == nil {
return strutil.PadLeft(" ", int(c.Width), ' ')
}
s := fmt.Sprintf("%v", c.Data)
if c.Width > 0 {
if c.Wrap && uint(len(s)) > c.Width {
return wordwrap.WrapString(s, c.Width)
} else {
return strutil.Resize(s, c.Width, c.RightAlign)
}
}
return s
} | [
"func",
"(",
"c",
"*",
"Cell",
")",
"String",
"(",
")",
"string",
"{",
"if",
"c",
".",
"Data",
"==",
"nil",
"{",
"return",
"strutil",
".",
"PadLeft",
"(",
"\"",
"\"",
",",
"int",
"(",
"c",
".",
"Width",
")",
",",
"' '",
")",
"\n",
"}",
"\n",
... | // String returns the string formated representation of the cell | [
"String",
"returns",
"the",
"string",
"formated",
"representation",
"of",
"the",
"cell"
] | 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 | https://github.com/gosuri/uitable/blob/36ee7e946282a3fb1cfecd476ddc9b35d8847e42/table.go#L190-L203 |
827 | raff/godet | godet.go | Host | func Host(host string) ConnectOption {
return func(c *httpclient.HttpClient) {
c.Host = host
}
} | go | func Host(host string) ConnectOption {
return func(c *httpclient.HttpClient) {
c.Host = host
}
} | [
"func",
"Host",
"(",
"host",
"string",
")",
"ConnectOption",
"{",
"return",
"func",
"(",
"c",
"*",
"httpclient",
".",
"HttpClient",
")",
"{",
"c",
".",
"Host",
"=",
"host",
"\n",
"}",
"\n",
"}"
] | // Host set the host header | [
"Host",
"set",
"the",
"host",
"header"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L233-L237 |
828 | raff/godet | godet.go | Headers | func Headers(headers map[string]string) ConnectOption {
return func(c *httpclient.HttpClient) {
c.Headers = headers
}
} | go | func Headers(headers map[string]string) ConnectOption {
return func(c *httpclient.HttpClient) {
c.Headers = headers
}
} | [
"func",
"Headers",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"ConnectOption",
"{",
"return",
"func",
"(",
"c",
"*",
"httpclient",
".",
"HttpClient",
")",
"{",
"c",
".",
"Headers",
"=",
"headers",
"\n",
"}",
"\n",
"}"
] | // Headers set specified HTTP headers | [
"Headers",
"set",
"specified",
"HTTP",
"headers"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L240-L244 |
829 | raff/godet | godet.go | Connect | func Connect(port string, verbose bool, options ...ConnectOption) (*RemoteDebugger, error) {
client := httpclient.NewHttpClient("http://" + port)
for _, setOption := range options {
setOption(client)
}
remote := &RemoteDebugger{
http: client,
requests: make(chan Params),
responses: map[int]chan json.RawMessage{},
callbacks: map[string]EventCallback{},
events: make(chan wsMessage, 256),
closed: make(chan bool),
verbose: verbose,
}
// remote.http.Verbose = verbose
if verbose {
httpclient.StartLogging(false, true, false)
}
if err := remote.connectWs(nil); err != nil {
return nil, err
}
go remote.sendMessages()
go remote.processEvents()
return remote, nil
} | go | func Connect(port string, verbose bool, options ...ConnectOption) (*RemoteDebugger, error) {
client := httpclient.NewHttpClient("http://" + port)
for _, setOption := range options {
setOption(client)
}
remote := &RemoteDebugger{
http: client,
requests: make(chan Params),
responses: map[int]chan json.RawMessage{},
callbacks: map[string]EventCallback{},
events: make(chan wsMessage, 256),
closed: make(chan bool),
verbose: verbose,
}
// remote.http.Verbose = verbose
if verbose {
httpclient.StartLogging(false, true, false)
}
if err := remote.connectWs(nil); err != nil {
return nil, err
}
go remote.sendMessages()
go remote.processEvents()
return remote, nil
} | [
"func",
"Connect",
"(",
"port",
"string",
",",
"verbose",
"bool",
",",
"options",
"...",
"ConnectOption",
")",
"(",
"*",
"RemoteDebugger",
",",
"error",
")",
"{",
"client",
":=",
"httpclient",
".",
"NewHttpClient",
"(",
"\"",
"\"",
"+",
"port",
")",
"\n\... | // Connect to the remote debugger and return `RemoteDebugger` object. | [
"Connect",
"to",
"the",
"remote",
"debugger",
"and",
"return",
"RemoteDebugger",
"object",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L247-L276 |
830 | raff/godet | godet.go | Close | func (remote *RemoteDebugger) Close() (err error) {
remote.Lock()
ws := remote.ws
remote.ws = nil
remote.Unlock()
if ws != nil { // already closed
close(remote.requests)
close(remote.closed)
err = ws.Close()
}
if remote.verbose {
httpclient.StopLogging()
}
return
} | go | func (remote *RemoteDebugger) Close() (err error) {
remote.Lock()
ws := remote.ws
remote.ws = nil
remote.Unlock()
if ws != nil { // already closed
close(remote.requests)
close(remote.closed)
err = ws.Close()
}
if remote.verbose {
httpclient.StopLogging()
}
return
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"Close",
"(",
")",
"(",
"err",
"error",
")",
"{",
"remote",
".",
"Lock",
"(",
")",
"\n",
"ws",
":=",
"remote",
".",
"ws",
"\n",
"remote",
".",
"ws",
"=",
"nil",
"\n",
"remote",
".",
"Unlock",
"("... | // Close the RemoteDebugger connection. | [
"Close",
"the",
"RemoteDebugger",
"connection",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L358-L375 |
831 | raff/godet | godet.go | SendRequest | func (remote *RemoteDebugger) SendRequest(method string, params Params) (map[string]interface{}, error) {
rawReply, err := remote.sendRawReplyRequest(method, params)
if err != nil || rawReply == nil {
return nil, err
}
return unmarshal(rawReply)
} | go | func (remote *RemoteDebugger) SendRequest(method string, params Params) (map[string]interface{}, error) {
rawReply, err := remote.sendRawReplyRequest(method, params)
if err != nil || rawReply == nil {
return nil, err
}
return unmarshal(rawReply)
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SendRequest",
"(",
"method",
"string",
",",
"params",
"Params",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"rawReply",
",",
"err",
":=",
"remote",
".",
"sendRa... | // SendRequest sends a request and returns the reply as a a map. | [
"SendRequest",
"sends",
"a",
"request",
"and",
"returns",
"the",
"reply",
"as",
"a",
"a",
"map",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L390-L396 |
832 | raff/godet | godet.go | sendRawReplyRequest | func (remote *RemoteDebugger) sendRawReplyRequest(method string, params Params) ([]byte, error) {
remote.Lock()
if remote.ws == nil {
remote.Unlock()
return nil, ErrorClose
}
responseChan := make(chan json.RawMessage, 1)
reqID := remote.reqID
remote.responses[reqID] = responseChan
remote.reqID++
remote.Unlock()
command := Params{
"id": reqID,
"method": method,
"params": params,
}
remote.requests <- command
reply := <-responseChan
remote.Lock()
delete(remote.responses, reqID)
remote.Unlock()
return reply, nil
} | go | func (remote *RemoteDebugger) sendRawReplyRequest(method string, params Params) ([]byte, error) {
remote.Lock()
if remote.ws == nil {
remote.Unlock()
return nil, ErrorClose
}
responseChan := make(chan json.RawMessage, 1)
reqID := remote.reqID
remote.responses[reqID] = responseChan
remote.reqID++
remote.Unlock()
command := Params{
"id": reqID,
"method": method,
"params": params,
}
remote.requests <- command
reply := <-responseChan
remote.Lock()
delete(remote.responses, reqID)
remote.Unlock()
return reply, nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"sendRawReplyRequest",
"(",
"method",
"string",
",",
"params",
"Params",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"remote",
".",
"Lock",
"(",
")",
"\n",
"if",
"remote",
".",
"ws",
"==",
"n... | // sendRawReplyRequest sends a request and returns the reply bytes. | [
"sendRawReplyRequest",
"sends",
"a",
"request",
"and",
"returns",
"the",
"reply",
"bytes",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L399-L426 |
833 | raff/godet | godet.go | Protocol | func (remote *RemoteDebugger) Protocol() (map[string]interface{}, error) {
resp, err := responseError(remote.http.Get("/json/protocol", nil, nil))
if err != nil {
return nil, err
}
var proto map[string]interface{}
if err = decode(resp, &proto); err != nil {
return nil, err
}
return proto, nil
} | go | func (remote *RemoteDebugger) Protocol() (map[string]interface{}, error) {
resp, err := responseError(remote.http.Get("/json/protocol", nil, nil))
if err != nil {
return nil, err
}
var proto map[string]interface{}
if err = decode(resp, &proto); err != nil {
return nil, err
}
return proto, nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"Protocol",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"responseError",
"(",
"remote",
".",
"http",
".",
"Get",
"(",
"\"",
"\... | // Protocol returns the DevTools protocol specification | [
"Protocol",
"returns",
"the",
"DevTools",
"protocol",
"specification"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L568-L580 |
834 | raff/godet | godet.go | ActivateTab | func (remote *RemoteDebugger) ActivateTab(tab *Tab) error {
resp, err := responseError(remote.http.Get("/json/activate/"+tab.ID, nil, nil))
resp.Close()
if err == nil {
err = remote.connectWs(tab)
}
return err
} | go | func (remote *RemoteDebugger) ActivateTab(tab *Tab) error {
resp, err := responseError(remote.http.Get("/json/activate/"+tab.ID, nil, nil))
resp.Close()
if err == nil {
err = remote.connectWs(tab)
}
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"ActivateTab",
"(",
"tab",
"*",
"Tab",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"responseError",
"(",
"remote",
".",
"http",
".",
"Get",
"(",
"\"",
"\"",
"+",
"tab",
".",
"ID",
",",
"nil",
",",... | // ActivateTab activates the specified tab. | [
"ActivateTab",
"activates",
"the",
"specified",
"tab",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L615-L624 |
835 | raff/godet | godet.go | CloseTab | func (remote *RemoteDebugger) CloseTab(tab *Tab) error {
resp, err := responseError(remote.http.Get("/json/close/"+tab.ID, nil, nil))
resp.Close()
return err
} | go | func (remote *RemoteDebugger) CloseTab(tab *Tab) error {
resp, err := responseError(remote.http.Get("/json/close/"+tab.ID, nil, nil))
resp.Close()
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"CloseTab",
"(",
"tab",
"*",
"Tab",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"responseError",
"(",
"remote",
".",
"http",
".",
"Get",
"(",
"\"",
"\"",
"+",
"tab",
".",
"ID",
",",
"nil",
",",
... | // CloseTab closes the specified tab. | [
"CloseTab",
"closes",
"the",
"specified",
"tab",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L627-L631 |
836 | raff/godet | godet.go | NewTab | func (remote *RemoteDebugger) NewTab(url string) (*Tab, error) {
path := "/json/new"
if url != "" {
path += "?" + url
}
resp, err := responseError(remote.http.Do(remote.http.Request("GET", path, nil, nil)))
if err != nil {
return nil, err
}
var tab Tab
if err = decode(resp, &tab); err != nil {
return nil, err
}
if err = remote.connectWs(&tab); err != nil {
return nil, err
}
return &tab, nil
} | go | func (remote *RemoteDebugger) NewTab(url string) (*Tab, error) {
path := "/json/new"
if url != "" {
path += "?" + url
}
resp, err := responseError(remote.http.Do(remote.http.Request("GET", path, nil, nil)))
if err != nil {
return nil, err
}
var tab Tab
if err = decode(resp, &tab); err != nil {
return nil, err
}
if err = remote.connectWs(&tab); err != nil {
return nil, err
}
return &tab, nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"NewTab",
"(",
"url",
"string",
")",
"(",
"*",
"Tab",
",",
"error",
")",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"if",
"url",
"!=",
"\"",
"\"",
"{",
"path",
"+=",
"\"",
"\"",
"+",
"url",
"\n",
"}"... | // NewTab creates a new tab. | [
"NewTab",
"creates",
"a",
"new",
"tab",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L634-L655 |
837 | raff/godet | godet.go | GetDomains | func (remote *RemoteDebugger) GetDomains() ([]Domain, error) {
res, err := remote.sendRawReplyRequest("Schema.getDomains", nil)
if err != nil {
return nil, err
}
var domains struct {
Domains []Domain
}
err = json.Unmarshal(res, &domains)
if err != nil {
return nil, err
}
return domains.Domains, nil
} | go | func (remote *RemoteDebugger) GetDomains() ([]Domain, error) {
res, err := remote.sendRawReplyRequest("Schema.getDomains", nil)
if err != nil {
return nil, err
}
var domains struct {
Domains []Domain
}
err = json.Unmarshal(res, &domains)
if err != nil {
return nil, err
}
return domains.Domains, nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"GetDomains",
"(",
")",
"(",
"[",
"]",
"Domain",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"remote",
".",
"sendRawReplyRequest",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"n... | // GetDomains lists the available DevTools domains. | [
"GetDomains",
"lists",
"the",
"available",
"DevTools",
"domains",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L658-L674 |
838 | raff/godet | godet.go | Navigate | func (remote *RemoteDebugger) Navigate(url string) (string, error) {
res, err := remote.SendRequest("Page.navigate", Params{
"url": url,
})
if err != nil {
return "", err
}
if errorText, ok := res["errorText"]; ok {
return "", NavigationError(errorText.(string))
}
frameID, ok := res["frameId"]
if !ok {
return "", nil
}
return frameID.(string), nil
} | go | func (remote *RemoteDebugger) Navigate(url string) (string, error) {
res, err := remote.SendRequest("Page.navigate", Params{
"url": url,
})
if err != nil {
return "", err
}
if errorText, ok := res["errorText"]; ok {
return "", NavigationError(errorText.(string))
}
frameID, ok := res["frameId"]
if !ok {
return "", nil
}
return frameID.(string), nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"Navigate",
"(",
"url",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"url",
","... | // Navigate navigates to the specified URL. | [
"Navigate",
"navigates",
"to",
"the",
"specified",
"URL",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L677-L694 |
839 | raff/godet | godet.go | Reload | func (remote *RemoteDebugger) Reload() error {
_, err := remote.SendRequest("Page.reload", Params{
"ignoreCache": true,
})
return err
} | go | func (remote *RemoteDebugger) Reload() error {
_, err := remote.SendRequest("Page.reload", Params{
"ignoreCache": true,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"Reload",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"true",
",",
"}",
")",
"\n\n",
"return",
"err",
"\n",
... | // Reload reloads the current page. | [
"Reload",
"reloads",
"the",
"current",
"page",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L697-L703 |
840 | raff/godet | godet.go | GetNavigationHistory | func (remote *RemoteDebugger) GetNavigationHistory() (int, []NavigationEntry, error) {
rawReply, err := remote.sendRawReplyRequest("Page.getNavigationHistory", nil)
if err != nil {
return 0, nil, err
}
var history struct {
Current int64 `json:"currentIndex"`
Entries []NavigationEntry `json:"entries"`
}
if err := json.Unmarshal(rawReply, &history); err != nil {
return 0, nil, err
}
return int(history.Current), history.Entries, nil
} | go | func (remote *RemoteDebugger) GetNavigationHistory() (int, []NavigationEntry, error) {
rawReply, err := remote.sendRawReplyRequest("Page.getNavigationHistory", nil)
if err != nil {
return 0, nil, err
}
var history struct {
Current int64 `json:"currentIndex"`
Entries []NavigationEntry `json:"entries"`
}
if err := json.Unmarshal(rawReply, &history); err != nil {
return 0, nil, err
}
return int(history.Current), history.Entries, nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"GetNavigationHistory",
"(",
")",
"(",
"int",
",",
"[",
"]",
"NavigationEntry",
",",
"error",
")",
"{",
"rawReply",
",",
"err",
":=",
"remote",
".",
"sendRawReplyRequest",
"(",
"\"",
"\"",
",",
"nil",
")... | // GetNavigationHistory returns navigation history for the current page. | [
"GetNavigationHistory",
"returns",
"navigation",
"history",
"for",
"the",
"current",
"page",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L706-L723 |
841 | raff/godet | godet.go | SetControlNavigations | func (remote *RemoteDebugger) SetControlNavigations(enabled bool) error {
_, err := remote.SendRequest("Page.setControlNavigations", Params{
"enabled": enabled,
})
return err
} | go | func (remote *RemoteDebugger) SetControlNavigations(enabled bool) error {
_, err := remote.SendRequest("Page.setControlNavigations", Params{
"enabled": enabled,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetControlNavigations",
"(",
"enabled",
"bool",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"enabled",
",",
"}",
")",
... | // SetControlNavigations toggles navigation throttling which allows programatic control over navigation and redirect response. | [
"SetControlNavigations",
"toggles",
"navigation",
"throttling",
"which",
"allows",
"programatic",
"control",
"over",
"navigation",
"and",
"redirect",
"response",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L726-L732 |
842 | raff/godet | godet.go | ProcessNavigation | func (remote *RemoteDebugger) ProcessNavigation(navigationID int, navigation NavigationResponse) error {
_, err := remote.SendRequest("Page.processNavigation", Params{
"response": navigation,
"navigationId": navigationID,
})
return err
} | go | func (remote *RemoteDebugger) ProcessNavigation(navigationID int, navigation NavigationResponse) error {
_, err := remote.SendRequest("Page.processNavigation", Params{
"response": navigation,
"navigationId": navigationID,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"ProcessNavigation",
"(",
"navigationID",
"int",
",",
"navigation",
"NavigationResponse",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
... | // ProcessNavigation should be sent in response to a navigationRequested or a redirectRequested event, telling the browser how to handle the navigation. | [
"ProcessNavigation",
"should",
"be",
"sent",
"in",
"response",
"to",
"a",
"navigationRequested",
"or",
"a",
"redirectRequested",
"event",
"telling",
"the",
"browser",
"how",
"to",
"handle",
"the",
"navigation",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L735-L742 |
843 | raff/godet | godet.go | CaptureScreenshot | func (remote *RemoteDebugger) CaptureScreenshot(format string, quality int, fromSurface bool) ([]byte, error) {
if format == "" {
format = "png"
}
res, err := remote.SendRequest("Page.captureScreenshot", Params{
"format": format,
"quality": quality,
"fromSurface": fromSurface,
})
if err != nil {
return nil, err
}
if res == nil {
return nil, ErrorNoResponse
}
return base64.StdEncoding.DecodeString(res["data"].(string))
} | go | func (remote *RemoteDebugger) CaptureScreenshot(format string, quality int, fromSurface bool) ([]byte, error) {
if format == "" {
format = "png"
}
res, err := remote.SendRequest("Page.captureScreenshot", Params{
"format": format,
"quality": quality,
"fromSurface": fromSurface,
})
if err != nil {
return nil, err
}
if res == nil {
return nil, ErrorNoResponse
}
return base64.StdEncoding.DecodeString(res["data"].(string))
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"CaptureScreenshot",
"(",
"format",
"string",
",",
"quality",
"int",
",",
"fromSurface",
"bool",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"format",
"==",
"\"",
"\"",
"{",
"format",
"="... | // CaptureScreenshot takes a screenshot, uses "png" as default format. | [
"CaptureScreenshot",
"takes",
"a",
"screenshot",
"uses",
"png",
"as",
"default",
"format",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L745-L765 |
844 | raff/godet | godet.go | SaveScreenshot | func (remote *RemoteDebugger) SaveScreenshot(filename string, perm os.FileMode, quality int, fromSurface bool) error {
var format string
ext := filepath.Ext(filename)
switch ext {
case ".jpg":
format = "jpeg"
case ".png":
format = "png"
default:
return errors.New("Image format not supported")
}
rawScreenshot, err := remote.CaptureScreenshot(format, quality, fromSurface)
if err != nil {
return err
}
return ioutil.WriteFile(filename, rawScreenshot, perm)
} | go | func (remote *RemoteDebugger) SaveScreenshot(filename string, perm os.FileMode, quality int, fromSurface bool) error {
var format string
ext := filepath.Ext(filename)
switch ext {
case ".jpg":
format = "jpeg"
case ".png":
format = "png"
default:
return errors.New("Image format not supported")
}
rawScreenshot, err := remote.CaptureScreenshot(format, quality, fromSurface)
if err != nil {
return err
}
return ioutil.WriteFile(filename, rawScreenshot, perm)
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SaveScreenshot",
"(",
"filename",
"string",
",",
"perm",
"os",
".",
"FileMode",
",",
"quality",
"int",
",",
"fromSurface",
"bool",
")",
"error",
"{",
"var",
"format",
"string",
"\n",
"ext",
":=",
"filepat... | // SaveScreenshot takes a screenshot and saves it to a file. | [
"SaveScreenshot",
"takes",
"a",
"screenshot",
"and",
"saves",
"it",
"to",
"a",
"file",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L768-L784 |
845 | raff/godet | godet.go | Dimensions | func Dimensions(width, height float64) PrintToPDFOption {
return func(o map[string]interface{}) {
o["paperWidth"] = width
o["paperHeight"] = height
}
} | go | func Dimensions(width, height float64) PrintToPDFOption {
return func(o map[string]interface{}) {
o["paperWidth"] = width
o["paperHeight"] = height
}
} | [
"func",
"Dimensions",
"(",
"width",
",",
"height",
"float64",
")",
"PrintToPDFOption",
"{",
"return",
"func",
"(",
"o",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"o",
"[",
"\"",
"\"",
"]",
"=",
"width",
"\n",
"o",
"[",
"\"",
"\"",... | // Dimensions sets the current page dimensions for PrintToPDF | [
"Dimensions",
"sets",
"the",
"current",
"page",
"dimensions",
"for",
"PrintToPDF"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L825-L830 |
846 | raff/godet | godet.go | Margins | func Margins(top, bottom, left, right float64) PrintToPDFOption {
return func(o map[string]interface{}) {
o["marginTop"] = top
o["marginBottom"] = bottom
o["marginLeft"] = left
o["marginRight"] = right
}
} | go | func Margins(top, bottom, left, right float64) PrintToPDFOption {
return func(o map[string]interface{}) {
o["marginTop"] = top
o["marginBottom"] = bottom
o["marginLeft"] = left
o["marginRight"] = right
}
} | [
"func",
"Margins",
"(",
"top",
",",
"bottom",
",",
"left",
",",
"right",
"float64",
")",
"PrintToPDFOption",
"{",
"return",
"func",
"(",
"o",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"o",
"[",
"\"",
"\"",
"]",
"=",
"top",
"\n",
... | // Margins sets the margin sizes for PrintToPDF | [
"Margins",
"sets",
"the",
"margin",
"sizes",
"for",
"PrintToPDF"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L833-L840 |
847 | raff/godet | godet.go | PrintToPDF | func (remote *RemoteDebugger) PrintToPDF(options ...PrintToPDFOption) ([]byte, error) {
mOptions := map[string]interface{}{}
for _, o := range options {
o(mOptions)
}
res, err := remote.SendRequest("Page.printToPDF", mOptions)
if err != nil {
return nil, err
}
if res == nil {
return nil, ErrorNoResponse
}
return base64.StdEncoding.DecodeString(res["data"].(string))
} | go | func (remote *RemoteDebugger) PrintToPDF(options ...PrintToPDFOption) ([]byte, error) {
mOptions := map[string]interface{}{}
for _, o := range options {
o(mOptions)
}
res, err := remote.SendRequest("Page.printToPDF", mOptions)
if err != nil {
return nil, err
}
if res == nil {
return nil, ErrorNoResponse
}
return base64.StdEncoding.DecodeString(res["data"].(string))
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"PrintToPDF",
"(",
"options",
"...",
"PrintToPDFOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"mOptions",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n\n",
"for",... | // PrintToPDF print the current page as PDF. | [
"PrintToPDF",
"print",
"the",
"current",
"page",
"as",
"PDF",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L850-L867 |
848 | raff/godet | godet.go | SavePDF | func (remote *RemoteDebugger) SavePDF(filename string, perm os.FileMode, options ...PrintToPDFOption) error {
rawPDF, err := remote.PrintToPDF(options...)
if err != nil {
return err
}
return ioutil.WriteFile(filename, rawPDF, perm)
} | go | func (remote *RemoteDebugger) SavePDF(filename string, perm os.FileMode, options ...PrintToPDFOption) error {
rawPDF, err := remote.PrintToPDF(options...)
if err != nil {
return err
}
return ioutil.WriteFile(filename, rawPDF, perm)
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SavePDF",
"(",
"filename",
"string",
",",
"perm",
"os",
".",
"FileMode",
",",
"options",
"...",
"PrintToPDFOption",
")",
"error",
"{",
"rawPDF",
",",
"err",
":=",
"remote",
".",
"PrintToPDF",
"(",
"option... | // SavePDF print current page as PDF and save to file | [
"SavePDF",
"print",
"current",
"page",
"as",
"PDF",
"and",
"save",
"to",
"file"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L870-L877 |
849 | raff/godet | godet.go | HandleJavaScriptDialog | func (remote *RemoteDebugger) HandleJavaScriptDialog(accept bool, promptText string) error {
_, err := remote.SendRequest("Page.handleJavaScriptDialog", Params{
"accept": accept,
"promptText": promptText,
})
return err
} | go | func (remote *RemoteDebugger) HandleJavaScriptDialog(accept bool, promptText string) error {
_, err := remote.SendRequest("Page.handleJavaScriptDialog", Params{
"accept": accept,
"promptText": promptText,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"HandleJavaScriptDialog",
"(",
"accept",
"bool",
",",
"promptText",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",... | // HandleJavaScriptDialog accepts or dismisses a Javascript initiated dialog. | [
"HandleJavaScriptDialog",
"accepts",
"or",
"dismisses",
"a",
"Javascript",
"initiated",
"dialog",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L880-L887 |
850 | raff/godet | godet.go | GetCookies | func (remote *RemoteDebugger) GetCookies(urls []string) ([]Cookie, error) {
params := Params{}
if urls != nil {
params["urls"] = urls
}
rawReply, err := remote.sendRawReplyRequest("Network.getCookies", params)
if err != nil {
return nil, err
}
var cookies struct {
Cookies []Cookie `json:"cookies"`
}
err = json.Unmarshal(rawReply, &cookies)
if err != nil {
log.Println("unmarshal:", err)
log.Println(string(rawReply))
return nil, err
}
return cookies.Cookies, nil
} | go | func (remote *RemoteDebugger) GetCookies(urls []string) ([]Cookie, error) {
params := Params{}
if urls != nil {
params["urls"] = urls
}
rawReply, err := remote.sendRawReplyRequest("Network.getCookies", params)
if err != nil {
return nil, err
}
var cookies struct {
Cookies []Cookie `json:"cookies"`
}
err = json.Unmarshal(rawReply, &cookies)
if err != nil {
log.Println("unmarshal:", err)
log.Println(string(rawReply))
return nil, err
}
return cookies.Cookies, nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"GetCookies",
"(",
"urls",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"Cookie",
",",
"error",
")",
"{",
"params",
":=",
"Params",
"{",
"}",
"\n\n",
"if",
"urls",
"!=",
"nil",
"{",
"params",
"[",
"\"",... | // GetCookies returns all browser cookies for the current URL.
// Depending on the backend support, will return detailed cookie information in the `cookies` field. | [
"GetCookies",
"returns",
"all",
"browser",
"cookies",
"for",
"the",
"current",
"URL",
".",
"Depending",
"on",
"the",
"backend",
"support",
"will",
"return",
"detailed",
"cookie",
"information",
"in",
"the",
"cookies",
"field",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L951-L976 |
851 | raff/godet | godet.go | GetAllCookies | func (remote *RemoteDebugger) GetAllCookies() ([]Cookie, error) {
rawReply, err := remote.sendRawReplyRequest("Network.getCookies", nil)
if err != nil {
return nil, err
}
var cookies struct {
Cookies []Cookie `json:"cookies"`
}
err = json.Unmarshal(rawReply, &cookies)
if err != nil {
log.Println("unmarshal:", err)
log.Println(string(rawReply))
return nil, err
}
return cookies.Cookies, nil
} | go | func (remote *RemoteDebugger) GetAllCookies() ([]Cookie, error) {
rawReply, err := remote.sendRawReplyRequest("Network.getCookies", nil)
if err != nil {
return nil, err
}
var cookies struct {
Cookies []Cookie `json:"cookies"`
}
err = json.Unmarshal(rawReply, &cookies)
if err != nil {
log.Println("unmarshal:", err)
log.Println(string(rawReply))
return nil, err
}
return cookies.Cookies, nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"GetAllCookies",
"(",
")",
"(",
"[",
"]",
"Cookie",
",",
"error",
")",
"{",
"rawReply",
",",
"err",
":=",
"remote",
".",
"sendRawReplyRequest",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!... | // GetAllCookies returns all browser cookies. Depending on the backend support,
// will return detailed cookie information in the `cookies` field. | [
"GetAllCookies",
"returns",
"all",
"browser",
"cookies",
".",
"Depending",
"on",
"the",
"backend",
"support",
"will",
"return",
"detailed",
"cookie",
"information",
"in",
"the",
"cookies",
"field",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L980-L999 |
852 | raff/godet | godet.go | SetRequestInterception | func (remote *RemoteDebugger) SetRequestInterception(patterns ...RequestPattern) error {
_, err := remote.SendRequest("Network.setRequestInterception", Params{
"patterns": patterns,
})
return err
} | go | func (remote *RemoteDebugger) SetRequestInterception(patterns ...RequestPattern) error {
_, err := remote.SendRequest("Network.setRequestInterception", Params{
"patterns": patterns,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetRequestInterception",
"(",
"patterns",
"...",
"RequestPattern",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"patterns",... | // SetRequestInterception sets the requests to intercept that match the provided patterns
// and optionally resource types. | [
"SetRequestInterception",
"sets",
"the",
"requests",
"to",
"intercept",
"that",
"match",
"the",
"provided",
"patterns",
"and",
"optionally",
"resource",
"types",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1034-L1039 |
853 | raff/godet | godet.go | EnableRequestInterception | func (remote *RemoteDebugger) EnableRequestInterception(enabled bool) error {
if enabled {
return remote.SetRequestInterception(RequestPattern{UrlPattern: "*"})
} else {
return remote.SetRequestInterception()
}
} | go | func (remote *RemoteDebugger) EnableRequestInterception(enabled bool) error {
if enabled {
return remote.SetRequestInterception(RequestPattern{UrlPattern: "*"})
} else {
return remote.SetRequestInterception()
}
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"EnableRequestInterception",
"(",
"enabled",
"bool",
")",
"error",
"{",
"if",
"enabled",
"{",
"return",
"remote",
".",
"SetRequestInterception",
"(",
"RequestPattern",
"{",
"UrlPattern",
":",
"\"",
"\"",
"}",
... | // EnableRequestInterception enables interception, modification or cancellation of network requests | [
"EnableRequestInterception",
"enables",
"interception",
"modification",
"or",
"cancellation",
"of",
"network",
"requests"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1042-L1048 |
854 | raff/godet | godet.go | QuerySelectorAll | func (remote *RemoteDebugger) QuerySelectorAll(nodeID int, selector string) (map[string]interface{}, error) {
return remote.SendRequest("DOM.querySelectorAll", Params{
"nodeId": nodeID,
"selector": selector,
})
} | go | func (remote *RemoteDebugger) QuerySelectorAll(nodeID int, selector string) (map[string]interface{}, error) {
return remote.SendRequest("DOM.querySelectorAll", Params{
"nodeId": nodeID,
"selector": selector,
})
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"QuerySelectorAll",
"(",
"nodeID",
"int",
",",
"selector",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"remote",
".",
"SendRequest",
"(",
"\"",... | // QuerySelectorAll gets a list of nodeId for the specified selectors. | [
"QuerySelectorAll",
"gets",
"a",
"list",
"of",
"nodeId",
"for",
"the",
"specified",
"selectors",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1112-L1117 |
855 | raff/godet | godet.go | ResolveNode | func (remote *RemoteDebugger) ResolveNode(nodeID int) (map[string]interface{}, error) {
return remote.SendRequest("DOM.resolveNode", Params{
"nodeId": nodeID,
})
} | go | func (remote *RemoteDebugger) ResolveNode(nodeID int) (map[string]interface{}, error) {
return remote.SendRequest("DOM.resolveNode", Params{
"nodeId": nodeID,
})
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"ResolveNode",
"(",
"nodeID",
"int",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"... | // ResolveNode returns some information about the node. | [
"ResolveNode",
"returns",
"some",
"information",
"about",
"the",
"node",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1120-L1124 |
856 | raff/godet | godet.go | RequestNode | func (remote *RemoteDebugger) RequestNode(nodeID int) error {
_, err := remote.SendRequest("DOM.requestChildNodes", Params{
"nodeId": nodeID,
})
return err
} | go | func (remote *RemoteDebugger) RequestNode(nodeID int) error {
_, err := remote.SendRequest("DOM.requestChildNodes", Params{
"nodeId": nodeID,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"RequestNode",
"(",
"nodeID",
"int",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"nodeID",
",",
"}",
")",
"\n\n",
"... | // RequestNode requests a node, the response is generated as a DOM.setChildNodes event. | [
"RequestNode",
"requests",
"a",
"node",
"the",
"response",
"is",
"generated",
"as",
"a",
"DOM",
".",
"setChildNodes",
"event",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1127-L1133 |
857 | raff/godet | godet.go | SetFileInputFiles | func (remote *RemoteDebugger) SetFileInputFiles(id int, files []string, idType IdType) error {
params := Params{"files": files}
switch idType {
case NodeId:
params["nodeId"] = id
case BackendNodeId:
params["backendNodeId"] = id
case ObjectId:
params["objectId"] = id
}
_, err := remote.SendRequest("DOM.setFileInputFiles", params)
return err
} | go | func (remote *RemoteDebugger) SetFileInputFiles(id int, files []string, idType IdType) error {
params := Params{"files": files}
switch idType {
case NodeId:
params["nodeId"] = id
case BackendNodeId:
params["backendNodeId"] = id
case ObjectId:
params["objectId"] = id
}
_, err := remote.SendRequest("DOM.setFileInputFiles", params)
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetFileInputFiles",
"(",
"id",
"int",
",",
"files",
"[",
"]",
"string",
",",
"idType",
"IdType",
")",
"error",
"{",
"params",
":=",
"Params",
"{",
"\"",
"\"",
":",
"files",
"}",
"\n\n",
"switch",
"idT... | // SetFileInputFiles sets files for the given file input element. | [
"SetFileInputFiles",
"sets",
"files",
"for",
"the",
"given",
"file",
"input",
"element",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1151-L1165 |
858 | raff/godet | godet.go | SetAttributeValue | func (remote *RemoteDebugger) SetAttributeValue(nodeID int, name, value string) error {
_, err := remote.SendRequest("DOM.setAttributeValue", Params{
"nodeId": nodeID,
"name": name,
"value": value,
})
return err
} | go | func (remote *RemoteDebugger) SetAttributeValue(nodeID int, name, value string) error {
_, err := remote.SendRequest("DOM.setAttributeValue", Params{
"nodeId": nodeID,
"name": name,
"value": value,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetAttributeValue",
"(",
"nodeID",
"int",
",",
"name",
",",
"value",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
... | // SetAttributeValue sets the value for a specified attribute. | [
"SetAttributeValue",
"sets",
"the",
"value",
"for",
"a",
"specified",
"attribute",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1168-L1176 |
859 | raff/godet | godet.go | GetOuterHTML | func (remote *RemoteDebugger) GetOuterHTML(nodeID int) (string, error) {
res, err := remote.SendRequest("DOM.getOuterHTML", Params{
"nodeId": nodeID,
})
if err != nil {
return "", err
}
return res["outerHTML"].(string), nil
} | go | func (remote *RemoteDebugger) GetOuterHTML(nodeID int) (string, error) {
res, err := remote.SendRequest("DOM.getOuterHTML", Params{
"nodeId": nodeID,
})
if err != nil {
return "", err
}
return res["outerHTML"].(string), nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"GetOuterHTML",
"(",
"nodeID",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"nodeID"... | // GetOuterHTML returns node's HTML markup. | [
"GetOuterHTML",
"returns",
"node",
"s",
"HTML",
"markup",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1179-L1189 |
860 | raff/godet | godet.go | SetOuterHTML | func (remote *RemoteDebugger) SetOuterHTML(nodeID int, outerHTML string) error {
_, err := remote.SendRequest("DOM.setOuterHTML", Params{
"nodeId": nodeID,
"outerHTML": outerHTML,
})
return err
} | go | func (remote *RemoteDebugger) SetOuterHTML(nodeID int, outerHTML string) error {
_, err := remote.SendRequest("DOM.setOuterHTML", Params{
"nodeId": nodeID,
"outerHTML": outerHTML,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetOuterHTML",
"(",
"nodeID",
"int",
",",
"outerHTML",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"nodeID",... | // SetOuterHTML sets node HTML markup. | [
"SetOuterHTML",
"sets",
"node",
"HTML",
"markup",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1192-L1199 |
861 | raff/godet | godet.go | SetDeviceMetricsOverride | func (remote *RemoteDebugger) SetDeviceMetricsOverride(width int, height int, deviceScaleFactor float64, mobile bool, fitWindow bool) error {
_, err := remote.SendRequest("Emulation.setDeviceMetricsOverride", Params{
"width": width,
"height": height,
"deviceScaleFactor": deviceScaleFactor,
"mobile": mobile,
"fitWindow": fitWindow})
return err
} | go | func (remote *RemoteDebugger) SetDeviceMetricsOverride(width int, height int, deviceScaleFactor float64, mobile bool, fitWindow bool) error {
_, err := remote.SendRequest("Emulation.setDeviceMetricsOverride", Params{
"width": width,
"height": height,
"deviceScaleFactor": deviceScaleFactor,
"mobile": mobile,
"fitWindow": fitWindow})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetDeviceMetricsOverride",
"(",
"width",
"int",
",",
"height",
"int",
",",
"deviceScaleFactor",
"float64",
",",
"mobile",
"bool",
",",
"fitWindow",
"bool",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote"... | // SetDeviceMetricsOverride sets mobile and fitWindow on top of device dimensions
// Can be used to produce screenshots of mobile viewports. | [
"SetDeviceMetricsOverride",
"sets",
"mobile",
"and",
"fitWindow",
"on",
"top",
"of",
"device",
"dimensions",
"Can",
"be",
"used",
"to",
"produce",
"screenshots",
"of",
"mobile",
"viewports",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1229-L1238 |
862 | raff/godet | godet.go | SendRune | func (remote *RemoteDebugger) SendRune(c rune) error {
if _, err := remote.SendRequest("Input.dispatchKeyEvent", Params{
"type": "rawKeyDown",
"windowsVirtualKeyCode": int(c),
"nativeVirtualKeyCode": int(c),
"unmodifiedText": string(c),
"text": string(c),
}); err != nil {
return err
}
if _, err := remote.SendRequest("Input.dispatchKeyEvent", Params{
"type": "char",
"windowsVirtualKeyCode": int(c),
"nativeVirtualKeyCode": int(c),
"unmodifiedText": string(c),
"text": string(c),
}); err != nil {
return err
}
_, err := remote.SendRequest("Input.dispatchKeyEvent", Params{
"type": "keyUp",
"windowsVirtualKeyCode": int(c),
"nativeVirtualKeyCode": int(c),
"unmodifiedText": string(c),
"text": string(c),
})
return err
} | go | func (remote *RemoteDebugger) SendRune(c rune) error {
if _, err := remote.SendRequest("Input.dispatchKeyEvent", Params{
"type": "rawKeyDown",
"windowsVirtualKeyCode": int(c),
"nativeVirtualKeyCode": int(c),
"unmodifiedText": string(c),
"text": string(c),
}); err != nil {
return err
}
if _, err := remote.SendRequest("Input.dispatchKeyEvent", Params{
"type": "char",
"windowsVirtualKeyCode": int(c),
"nativeVirtualKeyCode": int(c),
"unmodifiedText": string(c),
"text": string(c),
}); err != nil {
return err
}
_, err := remote.SendRequest("Input.dispatchKeyEvent", Params{
"type": "keyUp",
"windowsVirtualKeyCode": int(c),
"nativeVirtualKeyCode": int(c),
"unmodifiedText": string(c),
"text": string(c),
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SendRune",
"(",
"c",
"rune",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",... | // SendRune sends a character as keyboard input. | [
"SendRune",
"sends",
"a",
"character",
"as",
"keyboard",
"input",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1288-L1315 |
863 | raff/godet | godet.go | Evaluate | func (remote *RemoteDebugger) Evaluate(expr string) (interface{}, error) {
res, err := remote.SendRequest("Runtime.evaluate", Params{
"expression": expr,
"returnByValue": true,
})
if err != nil {
return nil, err
}
if res == nil {
return nil, nil
}
result := res["result"].(map[string]interface{})
if subtype, ok := result["subtype"]; ok && subtype.(string) == "error" {
// this is actually an error
exception := res["exceptionDetails"].(map[string]interface{})
return nil, EvaluateError{ErrorDetails: result, ExceptionDetails: exception}
}
return result["value"], nil
} | go | func (remote *RemoteDebugger) Evaluate(expr string) (interface{}, error) {
res, err := remote.SendRequest("Runtime.evaluate", Params{
"expression": expr,
"returnByValue": true,
})
if err != nil {
return nil, err
}
if res == nil {
return nil, nil
}
result := res["result"].(map[string]interface{})
if subtype, ok := result["subtype"]; ok && subtype.(string) == "error" {
// this is actually an error
exception := res["exceptionDetails"].(map[string]interface{})
return nil, EvaluateError{ErrorDetails: result, ExceptionDetails: exception}
}
return result["value"], nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"Evaluate",
"(",
"expr",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
"... | // Evaluate evalutes a Javascript function in the context of the current page. | [
"Evaluate",
"evalutes",
"a",
"Javascript",
"function",
"in",
"the",
"context",
"of",
"the",
"current",
"page",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1386-L1408 |
864 | raff/godet | godet.go | SetUserAgent | func (remote *RemoteDebugger) SetUserAgent(userAgent string) error {
_, err := remote.SendRequest("Network.setUserAgentOverride", Params{
"userAgent": userAgent,
})
return err
} | go | func (remote *RemoteDebugger) SetUserAgent(userAgent string) error {
_, err := remote.SendRequest("Network.setUserAgentOverride", Params{
"userAgent": userAgent,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetUserAgent",
"(",
"userAgent",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"userAgent",
",",
"}",
")",
"... | // SetUserAgent overrides the default user agent. | [
"SetUserAgent",
"overrides",
"the",
"default",
"user",
"agent",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1426-L1431 |
865 | raff/godet | godet.go | CallbackEvent | func (remote *RemoteDebugger) CallbackEvent(method string, cb EventCallback) {
remote.Lock()
remote.callbacks[method] = cb
remote.Unlock()
} | go | func (remote *RemoteDebugger) CallbackEvent(method string, cb EventCallback) {
remote.Lock()
remote.callbacks[method] = cb
remote.Unlock()
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"CallbackEvent",
"(",
"method",
"string",
",",
"cb",
"EventCallback",
")",
"{",
"remote",
".",
"Lock",
"(",
")",
"\n",
"remote",
".",
"callbacks",
"[",
"method",
"]",
"=",
"cb",
"\n",
"remote",
".",
"U... | // CallbackEvent sets a callback for the specified event. | [
"CallbackEvent",
"sets",
"a",
"callback",
"for",
"the",
"specified",
"event",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1465-L1469 |
866 | raff/godet | godet.go | StartProfiler | func (remote *RemoteDebugger) StartProfiler() error {
_, err := remote.SendRequest("Profiler.start", nil)
return err
} | go | func (remote *RemoteDebugger) StartProfiler() error {
_, err := remote.SendRequest("Profiler.start", nil)
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"StartProfiler",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // StartProfiler starts the profiler. | [
"StartProfiler",
"starts",
"the",
"profiler",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1472-L1475 |
867 | raff/godet | godet.go | SetProfilerSamplingInterval | func (remote *RemoteDebugger) SetProfilerSamplingInterval(n int64) error {
_, err := remote.SendRequest("Profiler.setSamplingInterval", Params{
"interval": n,
})
return err
} | go | func (remote *RemoteDebugger) SetProfilerSamplingInterval(n int64) error {
_, err := remote.SendRequest("Profiler.setSamplingInterval", Params{
"interval": n,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"SetProfilerSamplingInterval",
"(",
"n",
"int64",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"n",
",",
"}",
")",
"\n... | // SetProfilerSamplingInterval sets the profiler sampling interval in microseconds, must be called before StartProfiler. | [
"SetProfilerSamplingInterval",
"sets",
"the",
"profiler",
"sampling",
"interval",
"in",
"microseconds",
"must",
"be",
"called",
"before",
"StartProfiler",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1494-L1499 |
868 | raff/godet | godet.go | StartPreciseCoverage | func (remote *RemoteDebugger) StartPreciseCoverage(callCount, detailed bool) error {
_, err := remote.SendRequest("Profiler.startPreciseCoverage", Params{
"callCount": callCount,
"detailed": detailed,
})
return err
} | go | func (remote *RemoteDebugger) StartPreciseCoverage(callCount, detailed bool) error {
_, err := remote.SendRequest("Profiler.startPreciseCoverage", Params{
"callCount": callCount,
"detailed": detailed,
})
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"StartPreciseCoverage",
"(",
"callCount",
",",
"detailed",
"bool",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"callCount... | // StartPreciseCoverage enable precise code coverage. | [
"StartPreciseCoverage",
"enable",
"precise",
"code",
"coverage",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1502-L1508 |
869 | raff/godet | godet.go | StopPreciseCoverage | func (remote *RemoteDebugger) StopPreciseCoverage() error {
_, err := remote.SendRequest("Profiler.stopPreciseCoverage", nil)
return err
} | go | func (remote *RemoteDebugger) StopPreciseCoverage() error {
_, err := remote.SendRequest("Profiler.stopPreciseCoverage", nil)
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"StopPreciseCoverage",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // StopPreciseCoverage disable precise code coverage. | [
"StopPreciseCoverage",
"disable",
"precise",
"code",
"coverage",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1511-L1514 |
870 | raff/godet | godet.go | GetPreciseCoverage | func (remote *RemoteDebugger) GetPreciseCoverage(precise bool) ([]interface{}, error) {
var res map[string]interface{}
var err error
if precise {
res, err = remote.SendRequest("Profiler.takePreciseCoverage", nil)
} else {
res, err = remote.SendRequest("Profiler.getBestEffortCoverage", nil)
}
if res == nil || err != nil {
return nil, err
}
log.Println(res)
return res["result"].([]interface{}), nil
} | go | func (remote *RemoteDebugger) GetPreciseCoverage(precise bool) ([]interface{}, error) {
var res map[string]interface{}
var err error
if precise {
res, err = remote.SendRequest("Profiler.takePreciseCoverage", nil)
} else {
res, err = remote.SendRequest("Profiler.getBestEffortCoverage", nil)
}
if res == nil || err != nil {
return nil, err
}
log.Println(res)
return res["result"].([]interface{}), nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"GetPreciseCoverage",
"(",
"precise",
"bool",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"res",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"var",
"err",
"e... | // GetPreciseCoverage collects coverage data for the current isolate and resets execution counters. | [
"GetPreciseCoverage",
"collects",
"coverage",
"data",
"for",
"the",
"current",
"isolate",
"and",
"resets",
"execution",
"counters",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1517-L1531 |
871 | raff/godet | godet.go | CloseBrowser | func (remote *RemoteDebugger) CloseBrowser() {
_, err := remote.SendRequest("Browser.close", nil)
if err != nil {
log.Println(err)
}
} | go | func (remote *RemoteDebugger) CloseBrowser() {
_, err := remote.SendRequest("Browser.close", nil)
if err != nil {
log.Println(err)
}
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"CloseBrowser",
"(",
")",
"{",
"_",
",",
"err",
":=",
"remote",
".",
"SendRequest",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
... | // CloseBrowser gracefully closes the browser we are connected to | [
"CloseBrowser",
"gracefully",
"closes",
"the",
"browser",
"we",
"are",
"connected",
"to"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1534-L1539 |
872 | raff/godet | godet.go | DomainEvents | func (remote *RemoteDebugger) DomainEvents(domain string, enable bool) error {
method := domain
if enable {
method += ".enable"
} else {
method += ".disable"
}
_, err := remote.SendRequest(method, nil)
return err
} | go | func (remote *RemoteDebugger) DomainEvents(domain string, enable bool) error {
method := domain
if enable {
method += ".enable"
} else {
method += ".disable"
}
_, err := remote.SendRequest(method, nil)
return err
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"DomainEvents",
"(",
"domain",
"string",
",",
"enable",
"bool",
")",
"error",
"{",
"method",
":=",
"domain",
"\n\n",
"if",
"enable",
"{",
"method",
"+=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"method",
"... | // DomainEvents enables event listening in the specified domain. | [
"DomainEvents",
"enables",
"event",
"listening",
"in",
"the",
"specified",
"domain",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1542-L1553 |
873 | raff/godet | godet.go | AllEvents | func (remote *RemoteDebugger) AllEvents(enable bool) error {
domains, err := remote.GetDomains()
if err != nil {
return err
}
for _, domain := range domains {
if err := remote.DomainEvents(domain.Name, enable); err != nil {
return err
}
}
return nil
} | go | func (remote *RemoteDebugger) AllEvents(enable bool) error {
domains, err := remote.GetDomains()
if err != nil {
return err
}
for _, domain := range domains {
if err := remote.DomainEvents(domain.Name, enable); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"remote",
"*",
"RemoteDebugger",
")",
"AllEvents",
"(",
"enable",
"bool",
")",
"error",
"{",
"domains",
",",
"err",
":=",
"remote",
".",
"GetDomains",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"fo... | // AllEvents enables event listening for all domains. | [
"AllEvents",
"enables",
"event",
"listening",
"for",
"all",
"domains",
"."
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1556-L1569 |
874 | raff/godet | godet.go | ConsoleAPICallback | func ConsoleAPICallback(cb func([]interface{})) EventCallback {
return func(params Params) {
l := []interface{}{"console." + params["type"].(string)}
for _, a := range params["args"].([]interface{}) {
arg := a.(map[string]interface{})
if arg["value"] != nil {
l = append(l, arg["value"])
} else if arg["preview"] != nil {
arg := arg["preview"].(map[string]interface{})
v := arg["description"].(string) + "{"
for i, p := range arg["properties"].([]interface{}) {
if i > 0 {
v += ", "
}
prop := p.(map[string]interface{})
if prop["name"] != nil {
v += fmt.Sprintf("%q: ", prop["name"])
}
v += fmt.Sprintf("%v", prop["value"])
}
v += "}"
l = append(l, v)
} else {
l = append(l, arg["type"].(string))
}
}
cb(l)
}
} | go | func ConsoleAPICallback(cb func([]interface{})) EventCallback {
return func(params Params) {
l := []interface{}{"console." + params["type"].(string)}
for _, a := range params["args"].([]interface{}) {
arg := a.(map[string]interface{})
if arg["value"] != nil {
l = append(l, arg["value"])
} else if arg["preview"] != nil {
arg := arg["preview"].(map[string]interface{})
v := arg["description"].(string) + "{"
for i, p := range arg["properties"].([]interface{}) {
if i > 0 {
v += ", "
}
prop := p.(map[string]interface{})
if prop["name"] != nil {
v += fmt.Sprintf("%q: ", prop["name"])
}
v += fmt.Sprintf("%v", prop["value"])
}
v += "}"
l = append(l, v)
} else {
l = append(l, arg["type"].(string))
}
}
cb(l)
}
} | [
"func",
"ConsoleAPICallback",
"(",
"cb",
"func",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
")",
"EventCallback",
"{",
"return",
"func",
"(",
"params",
"Params",
")",
"{",
"l",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
"+",
"params",
... | // ConsoleAPICallback processes the Runtime.consolAPICalled event and returns printable info | [
"ConsoleAPICallback",
"processes",
"the",
"Runtime",
".",
"consolAPICalled",
"event",
"and",
"returns",
"printable",
"info"
] | ffd1c20237e94852e25b32797706416cdcf4f70f | https://github.com/raff/godet/blob/ffd1c20237e94852e25b32797706416cdcf4f70f/godet.go#L1607-L1644 |
875 | rancher/convoy | api/response.go | ResponseError | func ResponseError(format string, a ...interface{}) {
response := ErrorResponse{Error: fmt.Sprintf(format, a...)}
j, err := json.MarshalIndent(&response, "", "\t")
if err != nil {
panic(fmt.Sprintf("Failed to generate response for error:", err))
}
fmt.Println(string(j[:]))
} | go | func ResponseError(format string, a ...interface{}) {
response := ErrorResponse{Error: fmt.Sprintf(format, a...)}
j, err := json.MarshalIndent(&response, "", "\t")
if err != nil {
panic(fmt.Sprintf("Failed to generate response for error:", err))
}
fmt.Println(string(j[:]))
} | [
"func",
"ResponseError",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"response",
":=",
"ErrorResponse",
"{",
"Error",
":",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"a",
"...",
")",
"}",
"\n",
"j",
",",
"err",
":=",
... | // ResponseError would generate a error information in JSON format for output | [
"ResponseError",
"would",
"generate",
"a",
"error",
"information",
"in",
"JSON",
"format",
"for",
"output"
] | 23ae8d0da8fde882c9caa228efc39a38bc99f910 | https://github.com/rancher/convoy/blob/23ae8d0da8fde882c9caa228efc39a38bc99f910/api/response.go#L39-L46 |
876 | rancher/convoy | api/response.go | ResponseOutput | func ResponseOutput(v interface{}) ([]byte, error) {
j, err := json.MarshalIndent(v, "", "\t")
if err != nil {
return nil, err
}
return j, nil
} | go | func ResponseOutput(v interface{}) ([]byte, error) {
j, err := json.MarshalIndent(v, "", "\t")
if err != nil {
return nil, err
}
return j, nil
} | [
"func",
"ResponseOutput",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"j",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"v",
",",
"\"",
"\"",
",",
"\"",
"\\t",
"\"",
")",
"\n",
"if",
"err",
"!=",... | // ResponseOutput would generate a JSON format byte array of object for output | [
"ResponseOutput",
"would",
"generate",
"a",
"JSON",
"format",
"byte",
"array",
"of",
"object",
"for",
"output"
] | 23ae8d0da8fde882c9caa228efc39a38bc99f910 | https://github.com/rancher/convoy/blob/23ae8d0da8fde882c9caa228efc39a38bc99f910/api/response.go#L77-L83 |
877 | rancher/convoy | util/util.go | DecompressDir | func DecompressDir(sourceFile, targetDir string) error {
tmpDir := targetDir + ".tmp"
if _, err := Execute("rm", []string{"-rf", tmpDir}); err != nil {
return err
}
if err := os.Mkdir(tmpDir, os.ModeDir|0700); err != nil {
return err
}
if _, err := Execute("tar", []string{"xf", sourceFile, "-C", tmpDir}); err != nil {
return err
}
if _, err := Execute("rm", []string{"-rf", targetDir}); err != nil {
return err
}
if _, err := Execute("mv", []string{"-f", tmpDir, targetDir}); err != nil {
return err
}
return nil
} | go | func DecompressDir(sourceFile, targetDir string) error {
tmpDir := targetDir + ".tmp"
if _, err := Execute("rm", []string{"-rf", tmpDir}); err != nil {
return err
}
if err := os.Mkdir(tmpDir, os.ModeDir|0700); err != nil {
return err
}
if _, err := Execute("tar", []string{"xf", sourceFile, "-C", tmpDir}); err != nil {
return err
}
if _, err := Execute("rm", []string{"-rf", targetDir}); err != nil {
return err
}
if _, err := Execute("mv", []string{"-f", tmpDir, targetDir}); err != nil {
return err
}
return nil
} | [
"func",
"DecompressDir",
"(",
"sourceFile",
",",
"targetDir",
"string",
")",
"error",
"{",
"tmpDir",
":=",
"targetDir",
"+",
"\"",
"\"",
"\n",
"if",
"_",
",",
"err",
":=",
"Execute",
"(",
"\"",
"\"",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"... | // If sourceFile is inside targetDir, it would be deleted automatically | [
"If",
"sourceFile",
"is",
"inside",
"targetDir",
"it",
"would",
"be",
"deleted",
"automatically"
] | 23ae8d0da8fde882c9caa228efc39a38bc99f910 | https://github.com/rancher/convoy/blob/23ae8d0da8fde882c9caa228efc39a38bc99f910/util/util.go#L172-L190 |
878 | rancher/convoy | client/client.go | NewCli | func NewCli(version string) *cli.App {
app := cli.NewApp()
app.Name = "Convoy"
app.Version = version
app.Author = "Sheng Yang <sheng.yang@rancher.com>"
app.Usage = "A volume manager capable of snapshot and delta backup"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "socket, s",
Value: "/var/run/convoy/convoy.sock",
Usage: "Specify unix domain socket for communication between server and client",
},
cli.BoolFlag{
Name: "debug, d",
Usage: "Enable debug level log with client or not",
},
cli.BoolFlag{
Name: "verbose",
Usage: "Verbose level output for client, for create volume/snapshot etc",
},
}
app.CommandNotFound = cmdNotFound
app.Before = initClient
app.Commands = []cli.Command{
daemonCmd,
infoCmd,
volumeCreateCmd,
volumeDeleteCmd,
volumeMountCmd,
volumeUmountCmd,
volumeListCmd,
volumeInspectCmd,
snapshotCmd,
backupCmd,
}
return app
} | go | func NewCli(version string) *cli.App {
app := cli.NewApp()
app.Name = "Convoy"
app.Version = version
app.Author = "Sheng Yang <sheng.yang@rancher.com>"
app.Usage = "A volume manager capable of snapshot and delta backup"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "socket, s",
Value: "/var/run/convoy/convoy.sock",
Usage: "Specify unix domain socket for communication between server and client",
},
cli.BoolFlag{
Name: "debug, d",
Usage: "Enable debug level log with client or not",
},
cli.BoolFlag{
Name: "verbose",
Usage: "Verbose level output for client, for create volume/snapshot etc",
},
}
app.CommandNotFound = cmdNotFound
app.Before = initClient
app.Commands = []cli.Command{
daemonCmd,
infoCmd,
volumeCreateCmd,
volumeDeleteCmd,
volumeMountCmd,
volumeUmountCmd,
volumeListCmd,
volumeInspectCmd,
snapshotCmd,
backupCmd,
}
return app
} | [
"func",
"NewCli",
"(",
"version",
"string",
")",
"*",
"cli",
".",
"App",
"{",
"app",
":=",
"cli",
".",
"NewApp",
"(",
")",
"\n",
"app",
".",
"Name",
"=",
"\"",
"\"",
"\n",
"app",
".",
"Version",
"=",
"version",
"\n",
"app",
".",
"Author",
"=",
... | // NewCli would generate Convoy CLI | [
"NewCli",
"would",
"generate",
"Convoy",
"CLI"
] | 23ae8d0da8fde882c9caa228efc39a38bc99f910 | https://github.com/rancher/convoy/blob/23ae8d0da8fde882c9caa228efc39a38bc99f910/client/client.go#L119-L155 |
879 | rancher/convoy | logging/logging.go | ErrorWithFields | func ErrorWithFields(pkg string, fields logrus.Fields, format string, v ...interface{}) Error {
fields["pkg"] = pkg
entry := logrus.WithFields(fields)
entry.Message = fmt.Sprintf(format, v...)
return Error{entry, fmt.Errorf(format, v...)}
} | go | func ErrorWithFields(pkg string, fields logrus.Fields, format string, v ...interface{}) Error {
fields["pkg"] = pkg
entry := logrus.WithFields(fields)
entry.Message = fmt.Sprintf(format, v...)
return Error{entry, fmt.Errorf(format, v...)}
} | [
"func",
"ErrorWithFields",
"(",
"pkg",
"string",
",",
"fields",
"logrus",
".",
"Fields",
",",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"Error",
"{",
"fields",
"[",
"\"",
"\"",
"]",
"=",
"pkg",
"\n",
"entry",
":=",
"logrus",
".... | // ErrorWithFields is a helper for searchable error fields output | [
"ErrorWithFields",
"is",
"a",
"helper",
"for",
"searchable",
"error",
"fields",
"output"
] | 23ae8d0da8fde882c9caa228efc39a38bc99f910 | https://github.com/rancher/convoy/blob/23ae8d0da8fde882c9caa228efc39a38bc99f910/logging/logging.go#L80-L86 |
880 | asticode/go-astilectron-bundler | provisioner.go | NewProvisioner | func NewProvisioner(disembedFunc func(string) ([]byte, error)) astilectron.Provisioner {
return astilectron.NewDisembedderProvisioner(disembedFunc, filepath.Join(vendorDirectoryName, zipNameAstilectron), filepath.Join(vendorDirectoryName, zipNameElectron))
} | go | func NewProvisioner(disembedFunc func(string) ([]byte, error)) astilectron.Provisioner {
return astilectron.NewDisembedderProvisioner(disembedFunc, filepath.Join(vendorDirectoryName, zipNameAstilectron), filepath.Join(vendorDirectoryName, zipNameElectron))
} | [
"func",
"NewProvisioner",
"(",
"disembedFunc",
"func",
"(",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
")",
"astilectron",
".",
"Provisioner",
"{",
"return",
"astilectron",
".",
"NewDisembedderProvisioner",
"(",
"disembedFunc",
",",
"filepath",
"... | // NewProvisioner builds the proper disembedder provisioner | [
"NewProvisioner",
"builds",
"the",
"proper",
"disembedder",
"provisioner"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/provisioner.go#L17-L19 |
881 | asticode/go-astilectron-bundler | astilectron-bundler/ldflags.go | String | func (l LDFlags) String() string {
var o []string
keys := make([]string, 0, len(l))
for k := range l {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
ss := l[k]
if len(ss) == 0 {
o = append(o, "-"+k)
continue
}
for _, s := range ss {
o = append(o, fmt.Sprintf(`-%s %s`, k, s))
}
}
return strings.Join(o, " ")
} | go | func (l LDFlags) String() string {
var o []string
keys := make([]string, 0, len(l))
for k := range l {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
ss := l[k]
if len(ss) == 0 {
o = append(o, "-"+k)
continue
}
for _, s := range ss {
o = append(o, fmt.Sprintf(`-%s %s`, k, s))
}
}
return strings.Join(o, " ")
} | [
"func",
"(",
"l",
"LDFlags",
")",
"String",
"(",
")",
"string",
"{",
"var",
"o",
"[",
"]",
"string",
"\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"l",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"l",
"{",
"... | // String returns the ldflags as a string | [
"String",
"returns",
"the",
"ldflags",
"as",
"a",
"string"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/astilectron-bundler/ldflags.go#L13-L31 |
882 | asticode/go-astilectron-bundler | astilectron-bundler/ldflags.go | Set | func (l LDFlags) Set(s string) error {
segments := strings.SplitN(s, ":", 2)
flag := segments[0]
val := l[flag]
if len(segments) == 2 {
val = strings.Split(segments[1], ",")
}
l[flag] = append(l[flag], val...)
return nil
} | go | func (l LDFlags) Set(s string) error {
segments := strings.SplitN(s, ":", 2)
flag := segments[0]
val := l[flag]
if len(segments) == 2 {
val = strings.Split(segments[1], ",")
}
l[flag] = append(l[flag], val...)
return nil
} | [
"func",
"(",
"l",
"LDFlags",
")",
"Set",
"(",
"s",
"string",
")",
"error",
"{",
"segments",
":=",
"strings",
".",
"SplitN",
"(",
"s",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"flag",
":=",
"segments",
"[",
"0",
"]",
"\n\n",
"val",
":=",
"l",
"[",
... | // Set allows setting the values for use by flag | [
"Set",
"allows",
"setting",
"the",
"values",
"for",
"use",
"by",
"flag"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/astilectron-bundler/ldflags.go#L34-L45 |
883 | asticode/go-astilectron-bundler | bundler.go | absPath | func absPath(configPath string, defaultPathFn func() (string, error)) (o string, err error) {
if len(configPath) > 0 {
if o, err = filepath.Abs(configPath); err != nil {
err = errors.Wrapf(err, "filepath.Abs of %s failed", configPath)
return
}
} else if defaultPathFn != nil {
if o, err = defaultPathFn(); err != nil {
err = errors.Wrapf(err, "default path function to compute absPath of %s failed", configPath)
return
}
}
return
} | go | func absPath(configPath string, defaultPathFn func() (string, error)) (o string, err error) {
if len(configPath) > 0 {
if o, err = filepath.Abs(configPath); err != nil {
err = errors.Wrapf(err, "filepath.Abs of %s failed", configPath)
return
}
} else if defaultPathFn != nil {
if o, err = defaultPathFn(); err != nil {
err = errors.Wrapf(err, "default path function to compute absPath of %s failed", configPath)
return
}
}
return
} | [
"func",
"absPath",
"(",
"configPath",
"string",
",",
"defaultPathFn",
"func",
"(",
")",
"(",
"string",
",",
"error",
")",
")",
"(",
"o",
"string",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"configPath",
")",
">",
"0",
"{",
"if",
"o",
",",
... | // absPath computes the absolute path | [
"absPath",
"computes",
"the",
"absolute",
"path"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L144-L157 |
884 | asticode/go-astilectron-bundler | bundler.go | ClearCache | func (b *Bundler) ClearCache() (err error) {
// Remove cache folder
astilog.Debugf("Removing %s", b.pathCache)
if err = os.RemoveAll(b.pathCache); err != nil {
err = errors.Wrapf(err, "removing %s failed", b.pathCache)
return
}
return
} | go | func (b *Bundler) ClearCache() (err error) {
// Remove cache folder
astilog.Debugf("Removing %s", b.pathCache)
if err = os.RemoveAll(b.pathCache); err != nil {
err = errors.Wrapf(err, "removing %s failed", b.pathCache)
return
}
return
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"ClearCache",
"(",
")",
"(",
"err",
"error",
")",
"{",
"// Remove cache folder",
"astilog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"b",
".",
"pathCache",
")",
"\n",
"if",
"err",
"=",
"os",
".",
"RemoveAll",
"(",
... | // ClearCache clears the bundler cache | [
"ClearCache",
"clears",
"the",
"bundler",
"cache"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L303-L311 |
885 | asticode/go-astilectron-bundler | bundler.go | Bundle | func (b *Bundler) Bundle() (err error) {
// Create the output folder
astilog.Debugf("Creating %s", b.pathOutput)
if err = os.MkdirAll(b.pathOutput, 0755); err != nil {
err = errors.Wrapf(err, "mkdirall %s failed", b.pathOutput)
return
}
// Loop through environments
for _, e := range b.environments {
astilog.Debugf("Bundling for environment %s/%s", e.OS, e.Arch)
if err = b.bundle(e); err != nil {
err = errors.Wrapf(err, "bundling for environment %s/%s failed", e.OS, e.Arch)
return
}
}
return
} | go | func (b *Bundler) Bundle() (err error) {
// Create the output folder
astilog.Debugf("Creating %s", b.pathOutput)
if err = os.MkdirAll(b.pathOutput, 0755); err != nil {
err = errors.Wrapf(err, "mkdirall %s failed", b.pathOutput)
return
}
// Loop through environments
for _, e := range b.environments {
astilog.Debugf("Bundling for environment %s/%s", e.OS, e.Arch)
if err = b.bundle(e); err != nil {
err = errors.Wrapf(err, "bundling for environment %s/%s failed", e.OS, e.Arch)
return
}
}
return
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"Bundle",
"(",
")",
"(",
"err",
"error",
")",
"{",
"// Create the output folder",
"astilog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"b",
".",
"pathOutput",
")",
"\n",
"if",
"err",
"=",
"os",
".",
"MkdirAll",
"(",
... | // Bundle bundles an astilectron app based on a configuration | [
"Bundle",
"bundles",
"an",
"astilectron",
"app",
"based",
"on",
"a",
"configuration"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L314-L331 |
886 | asticode/go-astilectron-bundler | bundler.go | bundle | func (b *Bundler) bundle(e ConfigurationEnvironment) (err error) {
// Bind data
astilog.Debug("Binding data")
if err = b.BindData(e.OS, e.Arch); err != nil {
err = errors.Wrap(err, "binding data failed")
return
}
// Add windows .syso
if e.OS == "windows" {
if err = b.addWindowsSyso(e.Arch); err != nil {
err = errors.Wrap(err, "adding windows .syso failed")
return
}
}
// Reset output dir
var environmentPath = filepath.Join(b.pathOutput, e.OS+"-"+e.Arch)
if err = b.resetDir(environmentPath); err != nil {
err = errors.Wrapf(err, "resetting dir %s failed", environmentPath)
return
}
std := LDFlags{
"X": []string{
`main.AppName=` + b.appName,
`main.BuiltAt=` + time.Now().String(),
},
}
if e.OS == "windows" {
std["H"] = []string{"windowsgui"}
}
std.Merge(b.ldflags)
// Get gopath
gp := os.Getenv("GOPATH")
if len(gp) == 0 {
gp = build.Default.GOPATH
}
// Build cmd
astilog.Debugf("Building for os %s and arch %s", e.OS, e.Arch)
var binaryPath = filepath.Join(environmentPath, "binary")
var cmd = exec.Command(b.pathGoBinary, "build", "-ldflags", std.String(), "-o", binaryPath, b.pathBuild)
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env,
"GOARCH="+e.Arch,
"GOOS="+e.OS,
"GOPATH="+gp,
)
if e.EnvironmentVariables != nil {
for k, v := range e.EnvironmentVariables {
cmd.Env = append(cmd.Env, k+"="+v)
}
}
// Exec
var o []byte
astilog.Debugf("Executing %s", strings.Join(cmd.Args, " "))
if o, err = cmd.CombinedOutput(); err != nil {
err = errors.Wrapf(err, "building failed: %s", o)
return
}
// Finish bundle based on OS
switch e.OS {
case "darwin":
err = b.finishDarwin(environmentPath, binaryPath)
case "linux":
err = b.finishLinux(environmentPath, binaryPath)
case "windows":
err = b.finishWindows(environmentPath, binaryPath)
default:
err = fmt.Errorf("OS %s is not yet implemented", e.OS)
}
return
} | go | func (b *Bundler) bundle(e ConfigurationEnvironment) (err error) {
// Bind data
astilog.Debug("Binding data")
if err = b.BindData(e.OS, e.Arch); err != nil {
err = errors.Wrap(err, "binding data failed")
return
}
// Add windows .syso
if e.OS == "windows" {
if err = b.addWindowsSyso(e.Arch); err != nil {
err = errors.Wrap(err, "adding windows .syso failed")
return
}
}
// Reset output dir
var environmentPath = filepath.Join(b.pathOutput, e.OS+"-"+e.Arch)
if err = b.resetDir(environmentPath); err != nil {
err = errors.Wrapf(err, "resetting dir %s failed", environmentPath)
return
}
std := LDFlags{
"X": []string{
`main.AppName=` + b.appName,
`main.BuiltAt=` + time.Now().String(),
},
}
if e.OS == "windows" {
std["H"] = []string{"windowsgui"}
}
std.Merge(b.ldflags)
// Get gopath
gp := os.Getenv("GOPATH")
if len(gp) == 0 {
gp = build.Default.GOPATH
}
// Build cmd
astilog.Debugf("Building for os %s and arch %s", e.OS, e.Arch)
var binaryPath = filepath.Join(environmentPath, "binary")
var cmd = exec.Command(b.pathGoBinary, "build", "-ldflags", std.String(), "-o", binaryPath, b.pathBuild)
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env,
"GOARCH="+e.Arch,
"GOOS="+e.OS,
"GOPATH="+gp,
)
if e.EnvironmentVariables != nil {
for k, v := range e.EnvironmentVariables {
cmd.Env = append(cmd.Env, k+"="+v)
}
}
// Exec
var o []byte
astilog.Debugf("Executing %s", strings.Join(cmd.Args, " "))
if o, err = cmd.CombinedOutput(); err != nil {
err = errors.Wrapf(err, "building failed: %s", o)
return
}
// Finish bundle based on OS
switch e.OS {
case "darwin":
err = b.finishDarwin(environmentPath, binaryPath)
case "linux":
err = b.finishLinux(environmentPath, binaryPath)
case "windows":
err = b.finishWindows(environmentPath, binaryPath)
default:
err = fmt.Errorf("OS %s is not yet implemented", e.OS)
}
return
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"bundle",
"(",
"e",
"ConfigurationEnvironment",
")",
"(",
"err",
"error",
")",
"{",
"// Bind data",
"astilog",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"b",
".",
"BindData",
"(",
"e",
".",
"... | // bundle bundles an os | [
"bundle",
"bundles",
"an",
"os"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L334-L411 |
887 | asticode/go-astilectron-bundler | bundler.go | BindData | func (b *Bundler) BindData(os, arch string) (err error) {
// Reset bind dir
if err = b.resetDir(b.pathBindInput); err != nil {
err = errors.Wrapf(err, "resetting dir %s failed", b.pathBindInput)
return
}
// Provision the vendor
if err = b.provisionVendor(os, arch); err != nil {
err = errors.Wrap(err, "provisioning the vendor failed")
return
}
// Adapt resources
if err = b.adaptResources(); err != nil {
err = errors.Wrap(err, "adapting resources failed")
return
}
// Build bindata config
var c = bindata.NewConfig()
c.Input = []bindata.InputConfig{{Path: b.pathBindInput, Recursive: true}}
c.Output = filepath.Join(b.pathBindOutput, fmt.Sprintf("bind_%s_%s.go", os, arch))
c.Package = b.bindPackage
c.Prefix = b.pathBindInput
c.Tags = fmt.Sprintf("%s,%s", os, arch)
// Bind data
astilog.Debugf("Generating %s", c.Output)
err = bindata.Translate(c)
return
} | go | func (b *Bundler) BindData(os, arch string) (err error) {
// Reset bind dir
if err = b.resetDir(b.pathBindInput); err != nil {
err = errors.Wrapf(err, "resetting dir %s failed", b.pathBindInput)
return
}
// Provision the vendor
if err = b.provisionVendor(os, arch); err != nil {
err = errors.Wrap(err, "provisioning the vendor failed")
return
}
// Adapt resources
if err = b.adaptResources(); err != nil {
err = errors.Wrap(err, "adapting resources failed")
return
}
// Build bindata config
var c = bindata.NewConfig()
c.Input = []bindata.InputConfig{{Path: b.pathBindInput, Recursive: true}}
c.Output = filepath.Join(b.pathBindOutput, fmt.Sprintf("bind_%s_%s.go", os, arch))
c.Package = b.bindPackage
c.Prefix = b.pathBindInput
c.Tags = fmt.Sprintf("%s,%s", os, arch)
// Bind data
astilog.Debugf("Generating %s", c.Output)
err = bindata.Translate(c)
return
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"BindData",
"(",
"os",
",",
"arch",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Reset bind dir",
"if",
"err",
"=",
"b",
".",
"resetDir",
"(",
"b",
".",
"pathBindInput",
")",
";",
"err",
"!=",
"nil",
"{",... | // BindData binds the data | [
"BindData",
"binds",
"the",
"data"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L431-L462 |
888 | asticode/go-astilectron-bundler | bundler.go | provisionVendor | func (b *Bundler) provisionVendor(oS, arch string) (err error) {
// Create the vendor folder
astilog.Debugf("Creating %s", b.pathVendor)
if err = os.MkdirAll(b.pathVendor, 0755); err != nil {
err = errors.Wrapf(err, "mkdirall %s failed", b.pathVendor)
return
}
// Create the cache folder
astilog.Debugf("Creating %s", b.pathCache)
if err = os.MkdirAll(b.pathCache, 0755); err != nil {
err = errors.Wrapf(err, "mkdirall %s failed", b.pathCache)
return
}
// Provision astilectron
if err = b.provisionVendorAstilectron(); err != nil {
err = errors.Wrap(err, "provisioning astilectron vendor failed")
return
}
// Provision electron
if err = b.provisionVendorElectron(oS, arch); err != nil {
err = errors.Wrapf(err, "provisioning electron vendor for OS %s and arch %s failed", oS, arch)
return
}
return
} | go | func (b *Bundler) provisionVendor(oS, arch string) (err error) {
// Create the vendor folder
astilog.Debugf("Creating %s", b.pathVendor)
if err = os.MkdirAll(b.pathVendor, 0755); err != nil {
err = errors.Wrapf(err, "mkdirall %s failed", b.pathVendor)
return
}
// Create the cache folder
astilog.Debugf("Creating %s", b.pathCache)
if err = os.MkdirAll(b.pathCache, 0755); err != nil {
err = errors.Wrapf(err, "mkdirall %s failed", b.pathCache)
return
}
// Provision astilectron
if err = b.provisionVendorAstilectron(); err != nil {
err = errors.Wrap(err, "provisioning astilectron vendor failed")
return
}
// Provision electron
if err = b.provisionVendorElectron(oS, arch); err != nil {
err = errors.Wrapf(err, "provisioning electron vendor for OS %s and arch %s failed", oS, arch)
return
}
return
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"provisionVendor",
"(",
"oS",
",",
"arch",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Create the vendor folder",
"astilog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"b",
".",
"pathVendor",
")",
"\n",
"if",
"err... | // provisionVendor provisions the vendor folder | [
"provisionVendor",
"provisions",
"the",
"vendor",
"folder"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L465-L492 |
889 | asticode/go-astilectron-bundler | bundler.go | provisionVendorZip | func (b *Bundler) provisionVendorZip(pathDownload, pathCache, pathVendor string) (err error) {
// Download source
if _, errStat := os.Stat(pathCache); os.IsNotExist(errStat) {
if err = astilectron.Download(b.ctx, b.Client, pathDownload, pathCache); err != nil {
err = errors.Wrapf(err, "downloading %s into %s failed", pathDownload, pathCache)
return
}
} else {
astilog.Debugf("%s already exists, skipping download of %s", pathCache, pathDownload)
}
// Check context error
if b.ctx.Err() != nil {
return b.ctx.Err()
}
// Copy
astilog.Debugf("Copying %s to %s", pathCache, pathVendor)
if err = astios.Copy(b.ctx, pathCache, pathVendor); err != nil {
err = errors.Wrapf(err, "copying %s to %s failed", pathCache, pathVendor)
return
}
// Check context error
if b.ctx.Err() != nil {
return b.ctx.Err()
}
return
} | go | func (b *Bundler) provisionVendorZip(pathDownload, pathCache, pathVendor string) (err error) {
// Download source
if _, errStat := os.Stat(pathCache); os.IsNotExist(errStat) {
if err = astilectron.Download(b.ctx, b.Client, pathDownload, pathCache); err != nil {
err = errors.Wrapf(err, "downloading %s into %s failed", pathDownload, pathCache)
return
}
} else {
astilog.Debugf("%s already exists, skipping download of %s", pathCache, pathDownload)
}
// Check context error
if b.ctx.Err() != nil {
return b.ctx.Err()
}
// Copy
astilog.Debugf("Copying %s to %s", pathCache, pathVendor)
if err = astios.Copy(b.ctx, pathCache, pathVendor); err != nil {
err = errors.Wrapf(err, "copying %s to %s failed", pathCache, pathVendor)
return
}
// Check context error
if b.ctx.Err() != nil {
return b.ctx.Err()
}
return
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"provisionVendorZip",
"(",
"pathDownload",
",",
"pathCache",
",",
"pathVendor",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// Download source",
"if",
"_",
",",
"errStat",
":=",
"os",
".",
"Stat",
"(",
"pathCache",... | // provisionVendorZip provisions a vendor zip file | [
"provisionVendorZip",
"provisions",
"a",
"vendor",
"zip",
"file"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L495-L523 |
890 | asticode/go-astilectron-bundler | bundler.go | provisionVendorAstilectron | func (b *Bundler) provisionVendorAstilectron() (err error) {
var p = filepath.Join(b.pathCache, fmt.Sprintf("astilectron-%s.zip", astilectron.VersionAstilectron))
if len(b.pathAstilectron) > 0 {
// Zip
astilog.Debugf("Zipping %s into %s", b.pathAstilectron, p)
if err = astiarchive.Zip(b.ctx, b.pathAstilectron, p, fmt.Sprintf("astilectron-%s", astilectron.VersionAstilectron)); err != nil {
err = errors.Wrapf(err, "zipping %s into %s failed", b.pathAstilectron, p)
return
}
// Check context error
if b.ctx.Err() != nil {
return b.ctx.Err()
}
}
return b.provisionVendorZip(astilectron.AstilectronDownloadSrc(), p, filepath.Join(b.pathVendor, zipNameAstilectron))
} | go | func (b *Bundler) provisionVendorAstilectron() (err error) {
var p = filepath.Join(b.pathCache, fmt.Sprintf("astilectron-%s.zip", astilectron.VersionAstilectron))
if len(b.pathAstilectron) > 0 {
// Zip
astilog.Debugf("Zipping %s into %s", b.pathAstilectron, p)
if err = astiarchive.Zip(b.ctx, b.pathAstilectron, p, fmt.Sprintf("astilectron-%s", astilectron.VersionAstilectron)); err != nil {
err = errors.Wrapf(err, "zipping %s into %s failed", b.pathAstilectron, p)
return
}
// Check context error
if b.ctx.Err() != nil {
return b.ctx.Err()
}
}
return b.provisionVendorZip(astilectron.AstilectronDownloadSrc(), p, filepath.Join(b.pathVendor, zipNameAstilectron))
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"provisionVendorAstilectron",
"(",
")",
"(",
"err",
"error",
")",
"{",
"var",
"p",
"=",
"filepath",
".",
"Join",
"(",
"b",
".",
"pathCache",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"astilectron",
".",
... | // provisionVendorAstilectron provisions the astilectron vendor zip file | [
"provisionVendorAstilectron",
"provisions",
"the",
"astilectron",
"vendor",
"zip",
"file"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L526-L542 |
891 | asticode/go-astilectron-bundler | bundler.go | provisionVendorElectron | func (b *Bundler) provisionVendorElectron(oS, arch string) error {
return b.provisionVendorZip(astilectron.ElectronDownloadSrc(oS, arch), filepath.Join(b.pathCache, fmt.Sprintf("electron-%s-%s-%s.zip", oS, arch, astilectron.VersionElectron)), filepath.Join(b.pathVendor, zipNameElectron))
} | go | func (b *Bundler) provisionVendorElectron(oS, arch string) error {
return b.provisionVendorZip(astilectron.ElectronDownloadSrc(oS, arch), filepath.Join(b.pathCache, fmt.Sprintf("electron-%s-%s-%s.zip", oS, arch, astilectron.VersionElectron)), filepath.Join(b.pathVendor, zipNameElectron))
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"provisionVendorElectron",
"(",
"oS",
",",
"arch",
"string",
")",
"error",
"{",
"return",
"b",
".",
"provisionVendorZip",
"(",
"astilectron",
".",
"ElectronDownloadSrc",
"(",
"oS",
",",
"arch",
")",
",",
"filepath",
"... | // provisionVendorElectron provisions the electron vendor zip file | [
"provisionVendorElectron",
"provisions",
"the",
"electron",
"vendor",
"zip",
"file"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L545-L547 |
892 | asticode/go-astilectron-bundler | bundler.go | addWindowsSyso | func (b *Bundler) addWindowsSyso(arch string) (err error) {
if len(b.pathIconWindows) > 0 || len(b.pathManifest) > 0 {
var p = filepath.Join(b.pathInput, "windows.syso")
astilog.Debugf("Running rsrc for icon %s into %s", b.pathIconWindows, p)
if err = rsrc.Embed(p, arch, b.pathManifest, b.pathIconWindows); err != nil {
err = errors.Wrapf(err, "running rsrc for icon %s into %s failed", b.pathIconWindows, p)
return
}
}
return
} | go | func (b *Bundler) addWindowsSyso(arch string) (err error) {
if len(b.pathIconWindows) > 0 || len(b.pathManifest) > 0 {
var p = filepath.Join(b.pathInput, "windows.syso")
astilog.Debugf("Running rsrc for icon %s into %s", b.pathIconWindows, p)
if err = rsrc.Embed(p, arch, b.pathManifest, b.pathIconWindows); err != nil {
err = errors.Wrapf(err, "running rsrc for icon %s into %s failed", b.pathIconWindows, p)
return
}
}
return
} | [
"func",
"(",
"b",
"*",
"Bundler",
")",
"addWindowsSyso",
"(",
"arch",
"string",
")",
"(",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"b",
".",
"pathIconWindows",
")",
">",
"0",
"||",
"len",
"(",
"b",
".",
"pathManifest",
")",
">",
"0",
"{",
"var... | // addWindowsSyso adds the proper windows .syso if needed | [
"addWindowsSyso",
"adds",
"the",
"proper",
"windows",
".",
"syso",
"if",
"needed"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/bundler.go#L592-L602 |
893 | asticode/go-astilectron-bundler | ldflags.go | Merge | func (l LDFlags) Merge(r LDFlags) {
for flag := range r {
l[flag] = append(l[flag], r[flag]...)
}
} | go | func (l LDFlags) Merge(r LDFlags) {
for flag := range r {
l[flag] = append(l[flag], r[flag]...)
}
} | [
"func",
"(",
"l",
"LDFlags",
")",
"Merge",
"(",
"r",
"LDFlags",
")",
"{",
"for",
"flag",
":=",
"range",
"r",
"{",
"l",
"[",
"flag",
"]",
"=",
"append",
"(",
"l",
"[",
"flag",
"]",
",",
"r",
"[",
"flag",
"]",
"...",
")",
"\n",
"}",
"\n",
"}"... | // Merge merges ldflags | [
"Merge",
"merges",
"ldflags"
] | 155c2a10bbb1791fbafe89a9b64be05c64f16c81 | https://github.com/asticode/go-astilectron-bundler/blob/155c2a10bbb1791fbafe89a9b64be05c64f16c81/ldflags.go#L34-L38 |
894 | paulmach/go.geojson | properties.go | SetProperty | func (f *Feature) SetProperty(key string, value interface{}) {
if f.Properties == nil {
f.Properties = make(map[string]interface{})
}
f.Properties[key] = value
} | go | func (f *Feature) SetProperty(key string, value interface{}) {
if f.Properties == nil {
f.Properties = make(map[string]interface{})
}
f.Properties[key] = value
} | [
"func",
"(",
"f",
"*",
"Feature",
")",
"SetProperty",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"if",
"f",
".",
"Properties",
"==",
"nil",
"{",
"f",
".",
"Properties",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interfa... | // SetProperty provides the inverse of all the property functions
// and is here for consistency. | [
"SetProperty",
"provides",
"the",
"inverse",
"of",
"all",
"the",
"property",
"functions",
"and",
"is",
"here",
"for",
"consistency",
"."
] | a5c451da2d9c67c590ae6be92565b67698286a1a | https://github.com/paulmach/go.geojson/blob/a5c451da2d9c67c590ae6be92565b67698286a1a/properties.go#L9-L14 |
895 | paulmach/go.geojson | properties.go | PropertyBool | func (f *Feature) PropertyBool(key string) (bool, error) {
if b, ok := (f.Properties[key]).(bool); ok {
return b, nil
}
return false, fmt.Errorf("type assertion of `%s` to bool failed", key)
} | go | func (f *Feature) PropertyBool(key string) (bool, error) {
if b, ok := (f.Properties[key]).(bool); ok {
return b, nil
}
return false, fmt.Errorf("type assertion of `%s` to bool failed", key)
} | [
"func",
"(",
"f",
"*",
"Feature",
")",
"PropertyBool",
"(",
"key",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"b",
",",
"ok",
":=",
"(",
"f",
".",
"Properties",
"[",
"key",
"]",
")",
".",
"(",
"bool",
")",
";",
"ok",
"{",
"retu... | // PropertyBool type asserts a property to `bool`. | [
"PropertyBool",
"type",
"asserts",
"a",
"property",
"to",
"bool",
"."
] | a5c451da2d9c67c590ae6be92565b67698286a1a | https://github.com/paulmach/go.geojson/blob/a5c451da2d9c67c590ae6be92565b67698286a1a/properties.go#L17-L22 |
896 | paulmach/go.geojson | properties.go | PropertyInt | func (f *Feature) PropertyInt(key string) (int, error) {
if i, ok := (f.Properties[key]).(int); ok {
return i, nil
}
if i, ok := (f.Properties[key]).(float64); ok {
return int(i), nil
}
return 0, fmt.Errorf("type assertion of `%s` to int failed", key)
} | go | func (f *Feature) PropertyInt(key string) (int, error) {
if i, ok := (f.Properties[key]).(int); ok {
return i, nil
}
if i, ok := (f.Properties[key]).(float64); ok {
return int(i), nil
}
return 0, fmt.Errorf("type assertion of `%s` to int failed", key)
} | [
"func",
"(",
"f",
"*",
"Feature",
")",
"PropertyInt",
"(",
"key",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"i",
",",
"ok",
":=",
"(",
"f",
".",
"Properties",
"[",
"key",
"]",
")",
".",
"(",
"int",
")",
";",
"ok",
"{",
"return"... | // PropertyInt type asserts a property to `int`. | [
"PropertyInt",
"type",
"asserts",
"a",
"property",
"to",
"int",
"."
] | a5c451da2d9c67c590ae6be92565b67698286a1a | https://github.com/paulmach/go.geojson/blob/a5c451da2d9c67c590ae6be92565b67698286a1a/properties.go#L25-L35 |
897 | paulmach/go.geojson | properties.go | PropertyFloat64 | func (f *Feature) PropertyFloat64(key string) (float64, error) {
if i, ok := (f.Properties[key]).(float64); ok {
return i, nil
}
return 0, fmt.Errorf("type assertion of `%s` to float64 failed", key)
} | go | func (f *Feature) PropertyFloat64(key string) (float64, error) {
if i, ok := (f.Properties[key]).(float64); ok {
return i, nil
}
return 0, fmt.Errorf("type assertion of `%s` to float64 failed", key)
} | [
"func",
"(",
"f",
"*",
"Feature",
")",
"PropertyFloat64",
"(",
"key",
"string",
")",
"(",
"float64",
",",
"error",
")",
"{",
"if",
"i",
",",
"ok",
":=",
"(",
"f",
".",
"Properties",
"[",
"key",
"]",
")",
".",
"(",
"float64",
")",
";",
"ok",
"{"... | // PropertyFloat64 type asserts a property to `float64`. | [
"PropertyFloat64",
"type",
"asserts",
"a",
"property",
"to",
"float64",
"."
] | a5c451da2d9c67c590ae6be92565b67698286a1a | https://github.com/paulmach/go.geojson/blob/a5c451da2d9c67c590ae6be92565b67698286a1a/properties.go#L38-L43 |
898 | paulmach/go.geojson | properties.go | PropertyString | func (f *Feature) PropertyString(key string) (string, error) {
if s, ok := (f.Properties[key]).(string); ok {
return s, nil
}
return "", fmt.Errorf("type assertion of `%s` to string failed", key)
} | go | func (f *Feature) PropertyString(key string) (string, error) {
if s, ok := (f.Properties[key]).(string); ok {
return s, nil
}
return "", fmt.Errorf("type assertion of `%s` to string failed", key)
} | [
"func",
"(",
"f",
"*",
"Feature",
")",
"PropertyString",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"s",
",",
"ok",
":=",
"(",
"f",
".",
"Properties",
"[",
"key",
"]",
")",
".",
"(",
"string",
")",
";",
"ok",
"{",
... | // PropertyString type asserts a property to `string`. | [
"PropertyString",
"type",
"asserts",
"a",
"property",
"to",
"string",
"."
] | a5c451da2d9c67c590ae6be92565b67698286a1a | https://github.com/paulmach/go.geojson/blob/a5c451da2d9c67c590ae6be92565b67698286a1a/properties.go#L46-L51 |
899 | paulmach/go.geojson | feature.go | NewFeature | func NewFeature(geometry *Geometry) *Feature {
return &Feature{
Type: "Feature",
Geometry: geometry,
Properties: make(map[string]interface{}),
}
} | go | func NewFeature(geometry *Geometry) *Feature {
return &Feature{
Type: "Feature",
Geometry: geometry,
Properties: make(map[string]interface{}),
}
} | [
"func",
"NewFeature",
"(",
"geometry",
"*",
"Geometry",
")",
"*",
"Feature",
"{",
"return",
"&",
"Feature",
"{",
"Type",
":",
"\"",
"\"",
",",
"Geometry",
":",
"geometry",
",",
"Properties",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{"... | // NewFeature creates and initializes a GeoJSON feature given the required attributes. | [
"NewFeature",
"creates",
"and",
"initializes",
"a",
"GeoJSON",
"feature",
"given",
"the",
"required",
"attributes",
"."
] | a5c451da2d9c67c590ae6be92565b67698286a1a | https://github.com/paulmach/go.geojson/blob/a5c451da2d9c67c590ae6be92565b67698286a1a/feature.go#L18-L24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.