id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,200 | cbednarski/hostess | commands.go | Fixed | func Fixed(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
if bytes.Equal(hostsfile.GetData(), hostsfile.Format()) {
MaybePrintln(c, fmt.Sprintf("%s is already formatted and contains no dupes or conflicts", GetHostsPath()))
os.Exit(0)
} else {
MaybePrintln(c, fmt.Sprintf("%s is not formatted. Use hostess ... | go | func Fixed(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
if bytes.Equal(hostsfile.GetData(), hostsfile.Format()) {
MaybePrintln(c, fmt.Sprintf("%s is already formatted and contains no dupes or conflicts", GetHostsPath()))
os.Exit(0)
} else {
MaybePrintln(c, fmt.Sprintf("%s is not formatted. Use hostess ... | [
"func",
"Fixed",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"hostsfile",
":=",
"AlwaysLoadHostFile",
"(",
"c",
")",
"\n",
"if",
"bytes",
".",
"Equal",
"(",
"hostsfile",
".",
"GetData",
"(",
")",
",",
"hostsfile",
".",
"Format",
"(",
")",
")",
... | // Fixed command removes duplicates and conflicts from the hosts file | [
"Fixed",
"command",
"removes",
"duplicates",
"and",
"conflicts",
"from",
"the",
"hosts",
"file"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L248-L257 |
20,201 | cbednarski/hostess | commands.go | Dump | func Dump(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
jsonbytes, err := hostsfile.Hosts.Dump()
if err != nil {
MaybeError(c, err.Error())
}
fmt.Println(fmt.Sprintf("%s", jsonbytes))
} | go | func Dump(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
jsonbytes, err := hostsfile.Hosts.Dump()
if err != nil {
MaybeError(c, err.Error())
}
fmt.Println(fmt.Sprintf("%s", jsonbytes))
} | [
"func",
"Dump",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"hostsfile",
":=",
"AlwaysLoadHostFile",
"(",
"c",
")",
"\n",
"jsonbytes",
",",
"err",
":=",
"hostsfile",
".",
"Hosts",
".",
"Dump",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"May... | // Dump command outputs hosts file contents as JSON | [
"Dump",
"command",
"outputs",
"hosts",
"file",
"contents",
"as",
"JSON"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L260-L267 |
20,202 | cbednarski/hostess | commands.go | Apply | func Apply(c *cli.Context) {
if len(c.Args()) != 1 {
MaybeError(c, "Usage should be apply [filename]")
}
filename := c.Args()[0]
jsonbytes, err := ioutil.ReadFile(filename)
if err != nil {
MaybeError(c, fmt.Sprintf("Unable to read %s: %s", filename, err))
}
hostfile := AlwaysLoadHostFile(c)
err = hostfile... | go | func Apply(c *cli.Context) {
if len(c.Args()) != 1 {
MaybeError(c, "Usage should be apply [filename]")
}
filename := c.Args()[0]
jsonbytes, err := ioutil.ReadFile(filename)
if err != nil {
MaybeError(c, fmt.Sprintf("Unable to read %s: %s", filename, err))
}
hostfile := AlwaysLoadHostFile(c)
err = hostfile... | [
"func",
"Apply",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"!=",
"1",
"{",
"MaybeError",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"filename",
":=",
"c",
".",
"Args",
"(",
")",... | // Apply command adds hostnames to the hosts file from JSON | [
"Apply",
"command",
"adds",
"hostnames",
"to",
"the",
"hosts",
"file",
"from",
"JSON"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L270-L289 |
20,203 | cbednarski/hostess | hostfile.go | MustParseLine | func MustParseLine(line string) Hostlist {
hostlist, err := ParseLine(line)
if err != nil {
panic(err)
}
return hostlist
} | go | func MustParseLine(line string) Hostlist {
hostlist, err := ParseLine(line)
if err != nil {
panic(err)
}
return hostlist
} | [
"func",
"MustParseLine",
"(",
"line",
"string",
")",
"Hostlist",
"{",
"hostlist",
",",
"err",
":=",
"ParseLine",
"(",
"line",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"hostlist",
"\n",
"}"
] | // MustParseLine is like ParseLine but panics instead of errors. | [
"MustParseLine",
"is",
"like",
"ParseLine",
"but",
"panics",
"instead",
"of",
"errors",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostfile.go#L123-L129 |
20,204 | cbednarski/hostess | hostfile.go | Read | func (h *Hostfile) Read() error {
data, err := ioutil.ReadFile(h.Path)
if err == nil {
h.data = data
}
return err
} | go | func (h *Hostfile) Read() error {
data, err := ioutil.ReadFile(h.Path)
if err == nil {
h.data = data
}
return err
} | [
"func",
"(",
"h",
"*",
"Hostfile",
")",
"Read",
"(",
")",
"error",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"h",
".",
"Path",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"h",
".",
"data",
"=",
"data",
"\n",
"}",
"\n",
"ret... | // Read the contents of the hostfile from disk | [
"Read",
"the",
"contents",
"of",
"the",
"hostfile",
"from",
"disk"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostfile.go#L152-L158 |
20,205 | cbednarski/hostess | hostlist.go | Less | func (h Hostlist) Less(A, B int) bool {
// Sort IPv4 before IPv6
// A is IPv4 and B is IPv6. A wins!
if !h[A].IPv6 && h[B].IPv6 {
return true
}
// A is IPv6 but B is IPv4. A loses!
if h[A].IPv6 && !h[B].IPv6 {
return false
}
// Sort "localhost" at the top
if h[A].Domain == "localhost" {
return true
}
... | go | func (h Hostlist) Less(A, B int) bool {
// Sort IPv4 before IPv6
// A is IPv4 and B is IPv6. A wins!
if !h[A].IPv6 && h[B].IPv6 {
return true
}
// A is IPv6 but B is IPv4. A loses!
if h[A].IPv6 && !h[B].IPv6 {
return false
}
// Sort "localhost" at the top
if h[A].Domain == "localhost" {
return true
}
... | [
"func",
"(",
"h",
"Hostlist",
")",
"Less",
"(",
"A",
",",
"B",
"int",
")",
"bool",
"{",
"// Sort IPv4 before IPv6",
"// A is IPv4 and B is IPv6. A wins!",
"if",
"!",
"h",
"[",
"A",
"]",
".",
"IPv6",
"&&",
"h",
"[",
"B",
"]",
".",
"IPv6",
"{",
"return",... | // Less determines the sort order of two Hostnames, part of sort.Interface | [
"Less",
"determines",
"the",
"sort",
"order",
"of",
"two",
"Hostnames",
"part",
"of",
"sort",
".",
"Interface"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L52-L126 |
20,206 | cbednarski/hostess | hostlist.go | Swap | func (h Hostlist) Swap(i, j int) {
h[i], h[j] = h[j], h[i]
} | go | func (h Hostlist) Swap(i, j int) {
h[i], h[j] = h[j], h[i]
} | [
"func",
"(",
"h",
"Hostlist",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"h",
"[",
"i",
"]",
",",
"h",
"[",
"j",
"]",
"=",
"h",
"[",
"j",
"]",
",",
"h",
"[",
"i",
"]",
"\n",
"}"
] | // Swap changes the position of two Hostnames, part of sort.Interface | [
"Swap",
"changes",
"the",
"position",
"of",
"two",
"Hostnames",
"part",
"of",
"sort",
".",
"Interface"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L129-L131 |
20,207 | cbednarski/hostess | hostlist.go | Contains | func (h *Hostlist) Contains(b *Hostname) bool {
for _, a := range *h {
if a.Equal(b) {
return true
}
}
return false
} | go | func (h *Hostlist) Contains(b *Hostname) bool {
for _, a := range *h {
if a.Equal(b) {
return true
}
}
return false
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"Contains",
"(",
"b",
"*",
"Hostname",
")",
"bool",
"{",
"for",
"_",
",",
"a",
":=",
"range",
"*",
"h",
"{",
"if",
"a",
".",
"Equal",
"(",
"b",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
... | // Contains returns true if this Hostlist has the specified Hostname | [
"Contains",
"returns",
"true",
"if",
"this",
"Hostlist",
"has",
"the",
"specified",
"Hostname"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L144-L151 |
20,208 | cbednarski/hostess | hostlist.go | ContainsDomain | func (h *Hostlist) ContainsDomain(domain string) bool {
for _, hostname := range *h {
if hostname.Domain == domain {
return true
}
}
return false
} | go | func (h *Hostlist) ContainsDomain(domain string) bool {
for _, hostname := range *h {
if hostname.Domain == domain {
return true
}
}
return false
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"ContainsDomain",
"(",
"domain",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"hostname",
":=",
"range",
"*",
"h",
"{",
"if",
"hostname",
".",
"Domain",
"==",
"domain",
"{",
"return",
"true",
"\n",
"}",
"\n",
... | // ContainsDomain returns true if a Hostname in this Hostlist matches domain | [
"ContainsDomain",
"returns",
"true",
"if",
"a",
"Hostname",
"in",
"this",
"Hostlist",
"matches",
"domain"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L154-L161 |
20,209 | cbednarski/hostess | hostlist.go | ContainsIP | func (h *Hostlist) ContainsIP(IP net.IP) bool {
for _, hostname := range *h {
if hostname.EqualIP(IP) {
return true
}
}
return false
} | go | func (h *Hostlist) ContainsIP(IP net.IP) bool {
for _, hostname := range *h {
if hostname.EqualIP(IP) {
return true
}
}
return false
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"ContainsIP",
"(",
"IP",
"net",
".",
"IP",
")",
"bool",
"{",
"for",
"_",
",",
"hostname",
":=",
"range",
"*",
"h",
"{",
"if",
"hostname",
".",
"EqualIP",
"(",
"IP",
")",
"{",
"return",
"true",
"\n",
"}",
... | // ContainsIP returns true if a Hostname in this Hostlist matches IP | [
"ContainsIP",
"returns",
"true",
"if",
"a",
"Hostname",
"in",
"this",
"Hostlist",
"matches",
"IP"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L164-L171 |
20,210 | cbednarski/hostess | hostlist.go | IndexOf | func (h *Hostlist) IndexOf(host *Hostname) int {
for index, found := range *h {
if found.Equal(host) {
return index
}
}
return -1
} | go | func (h *Hostlist) IndexOf(host *Hostname) int {
for index, found := range *h {
if found.Equal(host) {
return index
}
}
return -1
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"IndexOf",
"(",
"host",
"*",
"Hostname",
")",
"int",
"{",
"for",
"index",
",",
"found",
":=",
"range",
"*",
"h",
"{",
"if",
"found",
".",
"Equal",
"(",
"host",
")",
"{",
"return",
"index",
"\n",
"}",
"\n",
... | // IndexOf will indicate the index of a Hostname in Hostlist, or -1 if it is
// not found. | [
"IndexOf",
"will",
"indicate",
"the",
"index",
"of",
"a",
"Hostname",
"in",
"Hostlist",
"or",
"-",
"1",
"if",
"it",
"is",
"not",
"found",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L208-L215 |
20,211 | cbednarski/hostess | hostlist.go | IndexOfDomainV | func (h *Hostlist) IndexOfDomainV(domain string, version int) int {
if version != 4 && version != 6 {
panic(ErrInvalidVersionArg)
}
for index, hostname := range *h {
if hostname.Domain == domain && hostname.IPv6 == (version == 6) {
return index
}
}
return -1
} | go | func (h *Hostlist) IndexOfDomainV(domain string, version int) int {
if version != 4 && version != 6 {
panic(ErrInvalidVersionArg)
}
for index, hostname := range *h {
if hostname.Domain == domain && hostname.IPv6 == (version == 6) {
return index
}
}
return -1
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"IndexOfDomainV",
"(",
"domain",
"string",
",",
"version",
"int",
")",
"int",
"{",
"if",
"version",
"!=",
"4",
"&&",
"version",
"!=",
"6",
"{",
"panic",
"(",
"ErrInvalidVersionArg",
")",
"\n",
"}",
"\n",
"for",
... | // IndexOfDomainV will indicate the index of a Hostname in Hostlist that has
// the same domain and IP version, or -1 if it is not found.
//
// This function will panic if IP version is not 4 or 6. | [
"IndexOfDomainV",
"will",
"indicate",
"the",
"index",
"of",
"a",
"Hostname",
"in",
"Hostlist",
"that",
"has",
"the",
"same",
"domain",
"and",
"IP",
"version",
"or",
"-",
"1",
"if",
"it",
"is",
"not",
"found",
".",
"This",
"function",
"will",
"panic",
"if... | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L221-L231 |
20,212 | cbednarski/hostess | hostlist.go | RemoveDomain | func (h *Hostlist) RemoveDomain(domain string) int {
return h.RemoveDomainV(domain, 4) + h.RemoveDomainV(domain, 6)
} | go | func (h *Hostlist) RemoveDomain(domain string) int {
return h.RemoveDomainV(domain, 4) + h.RemoveDomainV(domain, 6)
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"RemoveDomain",
"(",
"domain",
"string",
")",
"int",
"{",
"return",
"h",
".",
"RemoveDomainV",
"(",
"domain",
",",
"4",
")",
"+",
"h",
".",
"RemoveDomainV",
"(",
"domain",
",",
"6",
")",
"\n",
"}"
] | // RemoveDomain removes both IPv4 and IPv6 Hostname entries matching domain.
// Returns the number of entries removed. | [
"RemoveDomain",
"removes",
"both",
"IPv4",
"and",
"IPv6",
"Hostname",
"entries",
"matching",
"domain",
".",
"Returns",
"the",
"number",
"of",
"entries",
"removed",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L246-L248 |
20,213 | cbednarski/hostess | hostlist.go | RemoveDomainV | func (h *Hostlist) RemoveDomainV(domain string, version int) int {
return h.Remove(h.IndexOfDomainV(domain, version))
} | go | func (h *Hostlist) RemoveDomainV(domain string, version int) int {
return h.Remove(h.IndexOfDomainV(domain, version))
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"RemoveDomainV",
"(",
"domain",
"string",
",",
"version",
"int",
")",
"int",
"{",
"return",
"h",
".",
"Remove",
"(",
"h",
".",
"IndexOfDomainV",
"(",
"domain",
",",
"version",
")",
")",
"\n",
"}"
] | // RemoveDomainV removes a Hostname entry matching the domain and IP version. | [
"RemoveDomainV",
"removes",
"a",
"Hostname",
"entry",
"matching",
"the",
"domain",
"and",
"IP",
"version",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L251-L253 |
20,214 | cbednarski/hostess | hostlist.go | Enable | func (h *Hostlist) Enable(domain string) bool {
found := false
for _, hostname := range *h {
if hostname.Domain == domain {
hostname.Enabled = true
found = true
}
}
return found
} | go | func (h *Hostlist) Enable(domain string) bool {
found := false
for _, hostname := range *h {
if hostname.Domain == domain {
hostname.Enabled = true
found = true
}
}
return found
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"Enable",
"(",
"domain",
"string",
")",
"bool",
"{",
"found",
":=",
"false",
"\n",
"for",
"_",
",",
"hostname",
":=",
"range",
"*",
"h",
"{",
"if",
"hostname",
".",
"Domain",
"==",
"domain",
"{",
"hostname",
... | // Enable will change any Hostnames matching domain to be enabled. | [
"Enable",
"will",
"change",
"any",
"Hostnames",
"matching",
"domain",
"to",
"be",
"enabled",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L256-L265 |
20,215 | cbednarski/hostess | hostlist.go | EnableV | func (h *Hostlist) EnableV(domain string, version int) bool {
found := false
if version != 4 && version != 6 {
panic(ErrInvalidVersionArg)
}
for _, hostname := range *h {
if hostname.Domain == domain && hostname.IPv6 == (version == 6) {
hostname.Enabled = true
found = true
}
}
return found
} | go | func (h *Hostlist) EnableV(domain string, version int) bool {
found := false
if version != 4 && version != 6 {
panic(ErrInvalidVersionArg)
}
for _, hostname := range *h {
if hostname.Domain == domain && hostname.IPv6 == (version == 6) {
hostname.Enabled = true
found = true
}
}
return found
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"EnableV",
"(",
"domain",
"string",
",",
"version",
"int",
")",
"bool",
"{",
"found",
":=",
"false",
"\n",
"if",
"version",
"!=",
"4",
"&&",
"version",
"!=",
"6",
"{",
"panic",
"(",
"ErrInvalidVersionArg",
")",
... | // EnableV will change a Hostname matching domain and IP version to be enabled.
//
// This function will panic if IP version is not 4 or 6. | [
"EnableV",
"will",
"change",
"a",
"Hostname",
"matching",
"domain",
"and",
"IP",
"version",
"to",
"be",
"enabled",
".",
"This",
"function",
"will",
"panic",
"if",
"IP",
"version",
"is",
"not",
"4",
"or",
"6",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L270-L282 |
20,216 | cbednarski/hostess | hostlist.go | FilterByIP | func (h *Hostlist) FilterByIP(IP net.IP) (hostnames []*Hostname) {
for _, hostname := range *h {
if hostname.IP.Equal(IP) {
hostnames = append(hostnames, hostname)
}
}
return
} | go | func (h *Hostlist) FilterByIP(IP net.IP) (hostnames []*Hostname) {
for _, hostname := range *h {
if hostname.IP.Equal(IP) {
hostnames = append(hostnames, hostname)
}
}
return
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"FilterByIP",
"(",
"IP",
"net",
".",
"IP",
")",
"(",
"hostnames",
"[",
"]",
"*",
"Hostname",
")",
"{",
"for",
"_",
",",
"hostname",
":=",
"range",
"*",
"h",
"{",
"if",
"hostname",
".",
"IP",
".",
"Equal",
... | // FilterByIP filters the list of hostnames by IP address. | [
"FilterByIP",
"filters",
"the",
"list",
"of",
"hostnames",
"by",
"IP",
"address",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L314-L321 |
20,217 | cbednarski/hostess | hostlist.go | FilterByDomain | func (h *Hostlist) FilterByDomain(domain string) (hostnames []*Hostname) {
for _, hostname := range *h {
if hostname.Domain == domain {
hostnames = append(hostnames, hostname)
}
}
return
} | go | func (h *Hostlist) FilterByDomain(domain string) (hostnames []*Hostname) {
for _, hostname := range *h {
if hostname.Domain == domain {
hostnames = append(hostnames, hostname)
}
}
return
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"FilterByDomain",
"(",
"domain",
"string",
")",
"(",
"hostnames",
"[",
"]",
"*",
"Hostname",
")",
"{",
"for",
"_",
",",
"hostname",
":=",
"range",
"*",
"h",
"{",
"if",
"hostname",
".",
"Domain",
"==",
"domain",... | // FilterByDomain filters the list of hostnames by Domain. | [
"FilterByDomain",
"filters",
"the",
"list",
"of",
"hostnames",
"by",
"Domain",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L324-L331 |
20,218 | cbednarski/hostess | hostlist.go | FilterByDomainV | func (h *Hostlist) FilterByDomainV(domain string, version int) (hostnames []*Hostname) {
if version != 4 && version != 6 {
panic(ErrInvalidVersionArg)
}
for _, hostname := range *h {
if hostname.Domain == domain && hostname.IPv6 == (version == 6) {
hostnames = append(hostnames, hostname)
}
}
return
} | go | func (h *Hostlist) FilterByDomainV(domain string, version int) (hostnames []*Hostname) {
if version != 4 && version != 6 {
panic(ErrInvalidVersionArg)
}
for _, hostname := range *h {
if hostname.Domain == domain && hostname.IPv6 == (version == 6) {
hostnames = append(hostnames, hostname)
}
}
return
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"FilterByDomainV",
"(",
"domain",
"string",
",",
"version",
"int",
")",
"(",
"hostnames",
"[",
"]",
"*",
"Hostname",
")",
"{",
"if",
"version",
"!=",
"4",
"&&",
"version",
"!=",
"6",
"{",
"panic",
"(",
"ErrInva... | // FilterByDomainV filters the list of hostnames by domain and IPv4 or IPv6.
// This should never contain more than one item, but returns a list for
// consistency with other filter functions.
//
// This function will panic if IP version is not 4 or 6. | [
"FilterByDomainV",
"filters",
"the",
"list",
"of",
"hostnames",
"by",
"domain",
"and",
"IPv4",
"or",
"IPv6",
".",
"This",
"should",
"never",
"contain",
"more",
"than",
"one",
"item",
"but",
"returns",
"a",
"list",
"for",
"consistency",
"with",
"other",
"filt... | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L338-L348 |
20,219 | cbednarski/hostess | hostlist.go | Apply | func (h *Hostlist) Apply(jsonbytes []byte) error {
var hostnames Hostlist
err := json.Unmarshal(jsonbytes, &hostnames)
if err != nil {
return err
}
for _, hostname := range hostnames {
h.Add(hostname)
}
return nil
} | go | func (h *Hostlist) Apply(jsonbytes []byte) error {
var hostnames Hostlist
err := json.Unmarshal(jsonbytes, &hostnames)
if err != nil {
return err
}
for _, hostname := range hostnames {
h.Add(hostname)
}
return nil
} | [
"func",
"(",
"h",
"*",
"Hostlist",
")",
"Apply",
"(",
"jsonbytes",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"hostnames",
"Hostlist",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"jsonbytes",
",",
"&",
"hostnames",
")",
"\n",
"if",
"err",
"!="... | // Apply imports all entries from the JSON input to this Hostlist | [
"Apply",
"imports",
"all",
"entries",
"from",
"the",
"JSON",
"input",
"to",
"this",
"Hostlist"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostlist.go#L425-L437 |
20,220 | uber-common/bark | internal/callerskiphelper/callerskiphelper.go | LogWithBarker | func LogWithBarker(b bark.Logger, msg string) {
b.Error(fmt.Sprintf("logged from helper: %s", msg))
} | go | func LogWithBarker(b bark.Logger, msg string) {
b.Error(fmt.Sprintf("logged from helper: %s", msg))
} | [
"func",
"LogWithBarker",
"(",
"b",
"bark",
".",
"Logger",
",",
"msg",
"string",
")",
"{",
"b",
".",
"Error",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"msg",
")",
")",
"\n",
"}"
] | // LogWithBarker emits a log entry using a bark logger. | [
"LogWithBarker",
"emits",
"a",
"log",
"entry",
"using",
"a",
"bark",
"logger",
"."
] | 362cbdc2431a7f2414126b4fb4914820b876fad4 | https://github.com/uber-common/bark/blob/362cbdc2431a7f2414126b4fb4914820b876fad4/internal/callerskiphelper/callerskiphelper.go#L12-L14 |
20,221 | uber-common/bark | internal/callerskiphelper/callerskiphelper.go | LogWithZapper | func LogWithZapper(z *zap.Logger, msg string) {
z.Error(fmt.Sprintf("logged from helper: %s", msg))
} | go | func LogWithZapper(z *zap.Logger, msg string) {
z.Error(fmt.Sprintf("logged from helper: %s", msg))
} | [
"func",
"LogWithZapper",
"(",
"z",
"*",
"zap",
".",
"Logger",
",",
"msg",
"string",
")",
"{",
"z",
".",
"Error",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"msg",
")",
")",
"\n",
"}"
] | // LogWithZapper emits a log entry using a zap logger. | [
"LogWithZapper",
"emits",
"a",
"log",
"entry",
"using",
"a",
"zap",
"logger",
"."
] | 362cbdc2431a7f2414126b4fb4914820b876fad4 | https://github.com/uber-common/bark/blob/362cbdc2431a7f2414126b4fb4914820b876fad4/internal/callerskiphelper/callerskiphelper.go#L17-L19 |
20,222 | uber-common/bark | interface.go | NewNopLogger | func NewNopLogger() Logger {
return NewLoggerFromLogrus(&logrus.Logger{
Out: ioutil.Discard,
Formatter: new(logrus.JSONFormatter),
Level: logrus.DebugLevel,
})
} | go | func NewNopLogger() Logger {
return NewLoggerFromLogrus(&logrus.Logger{
Out: ioutil.Discard,
Formatter: new(logrus.JSONFormatter),
Level: logrus.DebugLevel,
})
} | [
"func",
"NewNopLogger",
"(",
")",
"Logger",
"{",
"return",
"NewLoggerFromLogrus",
"(",
"&",
"logrus",
".",
"Logger",
"{",
"Out",
":",
"ioutil",
".",
"Discard",
",",
"Formatter",
":",
"new",
"(",
"logrus",
".",
"JSONFormatter",
")",
",",
"Level",
":",
"lo... | // NewNopLogger creates a no-op logger. | [
"NewNopLogger",
"creates",
"a",
"no",
"-",
"op",
"logger",
"."
] | 362cbdc2431a7f2414126b4fb4914820b876fad4 | https://github.com/uber-common/bark/blob/362cbdc2431a7f2414126b4fb4914820b876fad4/interface.go#L106-L112 |
20,223 | uber-common/bark | zbark/barkify.go | Barkify | func Barkify(l *zap.Logger) bark.Logger {
if z, ok := l.Core().(*zapper); ok {
return z.l
}
return barker{l.WithOptions(zap.AddCallerSkip(_barkifyCallerSkip)).Sugar()}
} | go | func Barkify(l *zap.Logger) bark.Logger {
if z, ok := l.Core().(*zapper); ok {
return z.l
}
return barker{l.WithOptions(zap.AddCallerSkip(_barkifyCallerSkip)).Sugar()}
} | [
"func",
"Barkify",
"(",
"l",
"*",
"zap",
".",
"Logger",
")",
"bark",
".",
"Logger",
"{",
"if",
"z",
",",
"ok",
":=",
"l",
".",
"Core",
"(",
")",
".",
"(",
"*",
"zapper",
")",
";",
"ok",
"{",
"return",
"z",
".",
"l",
"\n",
"}",
"\n",
"return... | // Barkify wraps a zap logger in a compatibility layer so that it satisfies
// the bark.Logger interface. Note that the wrapper always returns nil from
// the Fields method, since zap doesn't support this functionality. | [
"Barkify",
"wraps",
"a",
"zap",
"logger",
"in",
"a",
"compatibility",
"layer",
"so",
"that",
"it",
"satisfies",
"the",
"bark",
".",
"Logger",
"interface",
".",
"Note",
"that",
"the",
"wrapper",
"always",
"returns",
"nil",
"from",
"the",
"Fields",
"method",
... | 362cbdc2431a7f2414126b4fb4914820b876fad4 | https://github.com/uber-common/bark/blob/362cbdc2431a7f2414126b4fb4914820b876fad4/zbark/barkify.go#L32-L37 |
20,224 | hashicorp/atlas-go | archive/archive.go | IsSet | func (o *ArchiveOpts) IsSet() bool {
return len(o.Exclude) > 0 || len(o.Include) > 0 || o.VCS
} | go | func (o *ArchiveOpts) IsSet() bool {
return len(o.Exclude) > 0 || len(o.Include) > 0 || o.VCS
} | [
"func",
"(",
"o",
"*",
"ArchiveOpts",
")",
"IsSet",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"o",
".",
"Exclude",
")",
">",
"0",
"||",
"len",
"(",
"o",
".",
"Include",
")",
">",
"0",
"||",
"o",
".",
"VCS",
"\n",
"}"
] | // IsSet says whether any options were set. | [
"IsSet",
"says",
"whether",
"any",
"options",
"were",
"set",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/archive.go#L49-L51 |
20,225 | hashicorp/atlas-go | archive/archive.go | CreateArchive | func CreateArchive(path string, opts *ArchiveOpts) (*Archive, error) {
log.Printf("[INFO] creating archive from %s", path)
// Dereference any symlinks and determine the real path and info
fi, err := os.Lstat(path)
if err != nil {
return nil, err
}
if fi.Mode()&os.ModeSymlink != 0 {
path, fi, err = readLinkFu... | go | func CreateArchive(path string, opts *ArchiveOpts) (*Archive, error) {
log.Printf("[INFO] creating archive from %s", path)
// Dereference any symlinks and determine the real path and info
fi, err := os.Lstat(path)
if err != nil {
return nil, err
}
if fi.Mode()&os.ModeSymlink != 0 {
path, fi, err = readLinkFu... | [
"func",
"CreateArchive",
"(",
"path",
"string",
",",
"opts",
"*",
"ArchiveOpts",
")",
"(",
"*",
"Archive",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n\n",
"// Dereference any symlinks and determine the real path and info"... | // CreateArchive takes the given path and ArchiveOpts and archives it.
//
// The archive will be fully completed and put into a temporary file.
// This must be done to retrieve the content length of the archive which
// is needed for almost all operations involving archives with Atlas. Because
// of this, sufficient di... | [
"CreateArchive",
"takes",
"the",
"given",
"path",
"and",
"ArchiveOpts",
"and",
"archives",
"it",
".",
"The",
"archive",
"will",
"be",
"fully",
"completed",
"and",
"put",
"into",
"a",
"temporary",
"file",
".",
"This",
"must",
"be",
"done",
"to",
"retrieve",
... | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/archive.go#L65-L95 |
20,226 | hashicorp/atlas-go | v1/application.go | CreateApp | func (c *Client) CreateApp(user, name string) (*App, error) {
log.Printf("[INFO] creating application %s/%s", user, name)
body, err := json.Marshal(&appWrapper{&App{
User: user,
Name: name,
}})
if err != nil {
return nil, err
}
endpoint := "/api/v1/vagrant/applications"
request, err := c.Request("POST", ... | go | func (c *Client) CreateApp(user, name string) (*App, error) {
log.Printf("[INFO] creating application %s/%s", user, name)
body, err := json.Marshal(&appWrapper{&App{
User: user,
Name: name,
}})
if err != nil {
return nil, err
}
endpoint := "/api/v1/vagrant/applications"
request, err := c.Request("POST", ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateApp",
"(",
"user",
",",
"name",
"string",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"user",
",",
"name",
")",
"\n\n",
"body",
",",
"err",
":=",
"json",... | // CreateApp creates a new App under the given user with the given name. If the
// App is created successfully, it is returned. If the server returns any
// errors, an error is returned. | [
"CreateApp",
"creates",
"a",
"new",
"App",
"under",
"the",
"given",
"user",
"with",
"the",
"given",
"name",
".",
"If",
"the",
"App",
"is",
"created",
"successfully",
"it",
"is",
"returned",
".",
"If",
"the",
"server",
"returns",
"any",
"errors",
"an",
"e... | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/application.go#L58-L91 |
20,227 | hashicorp/atlas-go | v1/application.go | UploadApp | func (c *Client) UploadApp(app *App, metadata map[string]interface{},
data io.Reader, size int64) (uint64, error) {
log.Printf("[INFO] uploading application %s (%d bytes) with metadata %q",
app.Slug(), size, metadata)
endpoint := fmt.Sprintf("/api/v1/vagrant/applications/%s/%s/versions",
app.User, app.Name)
... | go | func (c *Client) UploadApp(app *App, metadata map[string]interface{},
data io.Reader, size int64) (uint64, error) {
log.Printf("[INFO] uploading application %s (%d bytes) with metadata %q",
app.Slug(), size, metadata)
endpoint := fmt.Sprintf("/api/v1/vagrant/applications/%s/%s/versions",
app.User, app.Name)
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"UploadApp",
"(",
"app",
"*",
"App",
",",
"metadata",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"data",
"io",
".",
"Reader",
",",
"size",
"int64",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"log... | // UploadApp creates and uploads a new version for the App. If the server does not
// find the application, an error is returned. If the server does not accept the
// data, an error is returned.
//
// It is the responsibility of the caller to create a properly-formed data
// object; this method blindly passes along the... | [
"UploadApp",
"creates",
"and",
"uploads",
"a",
"new",
"version",
"for",
"the",
"App",
".",
"If",
"the",
"server",
"does",
"not",
"find",
"the",
"application",
"an",
"error",
"is",
"returned",
".",
"If",
"the",
"server",
"does",
"not",
"accept",
"the",
"d... | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/application.go#L113-L164 |
20,228 | hashicorp/atlas-go | v1/client.go | DefaultClient | func DefaultClient() *Client {
atlasEndpoint := os.Getenv(atlasEndpointEnvVar)
if atlasEndpoint == "" {
atlasEndpoint = atlasDefaultEndpoint
}
client, err := NewClient(atlasEndpoint)
if err != nil {
panic(err)
}
return client
} | go | func DefaultClient() *Client {
atlasEndpoint := os.Getenv(atlasEndpointEnvVar)
if atlasEndpoint == "" {
atlasEndpoint = atlasDefaultEndpoint
}
client, err := NewClient(atlasEndpoint)
if err != nil {
panic(err)
}
return client
} | [
"func",
"DefaultClient",
"(",
")",
"*",
"Client",
"{",
"atlasEndpoint",
":=",
"os",
".",
"Getenv",
"(",
"atlasEndpointEnvVar",
")",
"\n",
"if",
"atlasEndpoint",
"==",
"\"",
"\"",
"{",
"atlasEndpoint",
"=",
"atlasDefaultEndpoint",
"\n",
"}",
"\n\n",
"client",
... | // DefaultClient returns a client that connects to the Atlas API. | [
"DefaultClient",
"returns",
"a",
"client",
"that",
"connects",
"to",
"the",
"Atlas",
"API",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/client.go#L85-L97 |
20,229 | hashicorp/atlas-go | v1/client.go | Request | func (c *Client) Request(verb, spath string, ro *RequestOptions) (*http.Request, error) {
log.Printf("[INFO] request: %s %s", verb, spath)
// Ensure we have a RequestOptions struct (passing nil is an acceptable)
if ro == nil {
ro = new(RequestOptions)
}
// Create a new URL with the appended path
u := *c.URL
... | go | func (c *Client) Request(verb, spath string, ro *RequestOptions) (*http.Request, error) {
log.Printf("[INFO] request: %s %s", verb, spath)
// Ensure we have a RequestOptions struct (passing nil is an acceptable)
if ro == nil {
ro = new(RequestOptions)
}
// Create a new URL with the appended path
u := *c.URL
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Request",
"(",
"verb",
",",
"spath",
"string",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"verb",
",",
"spath... | // Request creates a new HTTP request using the given verb and sub path. | [
"Request",
"creates",
"a",
"new",
"HTTP",
"request",
"using",
"the",
"given",
"verb",
"and",
"sub",
"path",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/client.go#L169-L192 |
20,230 | hashicorp/atlas-go | v1/client.go | rawRequest | func (c *Client) rawRequest(verb string, u *url.URL, ro *RequestOptions) (*http.Request, error) {
if verb == "" {
return nil, fmt.Errorf("client: missing verb")
}
if u == nil {
return nil, fmt.Errorf("client: missing URL.url")
}
if ro == nil {
return nil, fmt.Errorf("client: missing RequestOptions")
}
/... | go | func (c *Client) rawRequest(verb string, u *url.URL, ro *RequestOptions) (*http.Request, error) {
if verb == "" {
return nil, fmt.Errorf("client: missing verb")
}
if u == nil {
return nil, fmt.Errorf("client: missing URL.url")
}
if ro == nil {
return nil, fmt.Errorf("client: missing RequestOptions")
}
/... | [
"func",
"(",
"c",
"*",
"Client",
")",
"rawRequest",
"(",
"verb",
"string",
",",
"u",
"*",
"url",
".",
"URL",
",",
"ro",
"*",
"RequestOptions",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"if",
"verb",
"==",
"\"",
"\"",
"{",
"... | // rawRequest accepts a verb, URL, and RequestOptions struct and returns the
// constructed http.Request and any errors that occurred | [
"rawRequest",
"accepts",
"a",
"verb",
"URL",
"and",
"RequestOptions",
"struct",
"and",
"returns",
"the",
"constructed",
"http",
".",
"Request",
"and",
"any",
"errors",
"that",
"occurred"
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/client.go#L219-L263 |
20,231 | hashicorp/atlas-go | v1/client.go | parseErr | func parseErr(r *http.Response) error {
re := &RailsError{}
if err := decodeJSON(r, &re); err != nil {
return fmt.Errorf("error decoding JSON body: %s", err)
}
return re
} | go | func parseErr(r *http.Response) error {
re := &RailsError{}
if err := decodeJSON(r, &re); err != nil {
return fmt.Errorf("error decoding JSON body: %s", err)
}
return re
} | [
"func",
"parseErr",
"(",
"r",
"*",
"http",
".",
"Response",
")",
"error",
"{",
"re",
":=",
"&",
"RailsError",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"decodeJSON",
"(",
"r",
",",
"&",
"re",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
... | // parseErr is used to take an error JSON response and return a single string
// for use in error messages. | [
"parseErr",
"is",
"used",
"to",
"take",
"an",
"error",
"JSON",
"response",
"and",
"return",
"a",
"single",
"string",
"for",
"use",
"in",
"error",
"messages",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/client.go#L312-L320 |
20,232 | hashicorp/atlas-go | v1/build_config.go | BuildConfig | func (c *Client) BuildConfig(user, name string) (*BuildConfig, error) {
log.Printf("[INFO] getting build configuration %s/%s", user, name)
endpoint := fmt.Sprintf("/api/v1/packer/build-configurations/%s/%s", user, name)
request, err := c.Request("GET", endpoint, nil)
if err != nil {
return nil, err
}
response... | go | func (c *Client) BuildConfig(user, name string) (*BuildConfig, error) {
log.Printf("[INFO] getting build configuration %s/%s", user, name)
endpoint := fmt.Sprintf("/api/v1/packer/build-configurations/%s/%s", user, name)
request, err := c.Request("GET", endpoint, nil)
if err != nil {
return nil, err
}
response... | [
"func",
"(",
"c",
"*",
"Client",
")",
"BuildConfig",
"(",
"user",
",",
"name",
"string",
")",
"(",
"*",
"BuildConfig",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"user",
",",
"name",
")",
"\n\n",
"endpoint",
":=",
"fmt",
... | // BuildConfig gets a single build configuration by user and name. | [
"BuildConfig",
"gets",
"a",
"single",
"build",
"configuration",
"by",
"user",
"and",
"name",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/build_config.go#L72-L92 |
20,233 | hashicorp/atlas-go | v1/build_config.go | CreateBuildConfig | func (c *Client) CreateBuildConfig(user, name string) (*BuildConfig, error) {
log.Printf("[INFO] creating build configuration %s/%s", user, name)
endpoint := "/api/v1/packer/build-configurations"
body, err := json.Marshal(&bcWrapper{
BuildConfig: &BuildConfig{
User: user,
Name: name,
},
})
if err != nil... | go | func (c *Client) CreateBuildConfig(user, name string) (*BuildConfig, error) {
log.Printf("[INFO] creating build configuration %s/%s", user, name)
endpoint := "/api/v1/packer/build-configurations"
body, err := json.Marshal(&bcWrapper{
BuildConfig: &BuildConfig{
User: user,
Name: name,
},
})
if err != nil... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateBuildConfig",
"(",
"user",
",",
"name",
"string",
")",
"(",
"*",
"BuildConfig",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"user",
",",
"name",
")",
"\n\n",
"endpoint",
":=",
"\"... | // CreateBuildConfig creates a new build configuration. | [
"CreateBuildConfig",
"creates",
"a",
"new",
"build",
"configuration",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/build_config.go#L95-L130 |
20,234 | hashicorp/atlas-go | v1/artifact.go | MarshalJSON | func (o *UploadArtifactOpts) MarshalJSON() ([]byte, error) {
return json.Marshal(map[string]interface{}{
"artifact_version": map[string]interface{}{
"id": o.ID,
"file": o.File != nil,
"metadata": o.Metadata,
"build_id": o.BuildID,
"compile_id": o.CompileID,
},
})
} | go | func (o *UploadArtifactOpts) MarshalJSON() ([]byte, error) {
return json.Marshal(map[string]interface{}{
"artifact_version": map[string]interface{}{
"id": o.ID,
"file": o.File != nil,
"metadata": o.Metadata,
"build_id": o.BuildID,
"compile_id": o.CompileID,
},
})
} | [
"func",
"(",
"o",
"*",
"UploadArtifactOpts",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"map",
"[",
"... | // MarshalJSON converts the UploadArtifactOpts into a JSON struct. | [
"MarshalJSON",
"converts",
"the",
"UploadArtifactOpts",
"into",
"a",
"JSON",
"struct",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/artifact.go#L62-L72 |
20,235 | hashicorp/atlas-go | v1/artifact.go | Artifact | func (c *Client) Artifact(user, name string) (*Artifact, error) {
endpoint := fmt.Sprintf("/api/v1/artifacts/%s/%s", user, name)
request, err := c.Request("GET", endpoint, nil)
if err != nil {
return nil, err
}
response, err := checkResp(c.HTTPClient.Do(request))
if err != nil {
return nil, err
}
var aw a... | go | func (c *Client) Artifact(user, name string) (*Artifact, error) {
endpoint := fmt.Sprintf("/api/v1/artifacts/%s/%s", user, name)
request, err := c.Request("GET", endpoint, nil)
if err != nil {
return nil, err
}
response, err := checkResp(c.HTTPClient.Do(request))
if err != nil {
return nil, err
}
var aw a... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Artifact",
"(",
"user",
",",
"name",
"string",
")",
"(",
"*",
"Artifact",
",",
"error",
")",
"{",
"endpoint",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"user",
",",
"name",
")",
"\n",
"request",
","... | // Artifact finds the Atlas artifact by the given name and returns it. Any
// errors that occur are returned, including ErrAuth and ErrNotFound special
// exceptions which the user may want to handle separately. | [
"Artifact",
"finds",
"the",
"Atlas",
"artifact",
"by",
"the",
"given",
"name",
"and",
"returns",
"it",
".",
"Any",
"errors",
"that",
"occur",
"are",
"returned",
"including",
"ErrAuth",
"and",
"ErrNotFound",
"special",
"exceptions",
"which",
"the",
"user",
"may... | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/artifact.go#L81-L99 |
20,236 | hashicorp/atlas-go | v1/artifact.go | ArtifactSearch | func (c *Client) ArtifactSearch(opts *ArtifactSearchOpts) ([]*ArtifactVersion, error) {
log.Printf("[INFO] searching artifacts: %#v", opts)
params := make(map[string]string)
if opts.Version != "" {
params["version"] = opts.Version
}
if opts.Build != "" {
params["build"] = opts.Build
}
i := 1
for k, v := r... | go | func (c *Client) ArtifactSearch(opts *ArtifactSearchOpts) ([]*ArtifactVersion, error) {
log.Printf("[INFO] searching artifacts: %#v", opts)
params := make(map[string]string)
if opts.Version != "" {
params["version"] = opts.Version
}
if opts.Build != "" {
params["build"] = opts.Build
}
i := 1
for k, v := r... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ArtifactSearch",
"(",
"opts",
"*",
"ArtifactSearchOpts",
")",
"(",
"[",
"]",
"*",
"ArtifactVersion",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"opts",
")",
"\n\n",
"params",
":=",
"make... | // ArtifactSearch searches Atlas for the given ArtifactSearchOpts and returns
// a slice of ArtifactVersions. | [
"ArtifactSearch",
"searches",
"Atlas",
"for",
"the",
"given",
"ArtifactSearchOpts",
"and",
"returns",
"a",
"slice",
"of",
"ArtifactVersions",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/artifact.go#L103-L145 |
20,237 | hashicorp/atlas-go | v1/artifact.go | CreateArtifact | func (c *Client) CreateArtifact(user, name string) (*Artifact, error) {
log.Printf("[INFO] creating artifact: %s/%s", user, name)
body, err := json.Marshal(&artifactWrapper{&Artifact{
User: user,
Name: name,
}})
if err != nil {
return nil, err
}
endpoint := "/api/v1/artifacts"
request, err := c.Request("P... | go | func (c *Client) CreateArtifact(user, name string) (*Artifact, error) {
log.Printf("[INFO] creating artifact: %s/%s", user, name)
body, err := json.Marshal(&artifactWrapper{&Artifact{
User: user,
Name: name,
}})
if err != nil {
return nil, err
}
endpoint := "/api/v1/artifacts"
request, err := c.Request("P... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateArtifact",
"(",
"user",
",",
"name",
"string",
")",
"(",
"*",
"Artifact",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"user",
",",
"name",
")",
"\n",
"body",
",",
"err",
":=",
... | // CreateArtifact creates and returns a new Artifact in Atlas. Any errors that
// occurr are returned. | [
"CreateArtifact",
"creates",
"and",
"returns",
"a",
"new",
"Artifact",
"in",
"Atlas",
".",
"Any",
"errors",
"that",
"occurr",
"are",
"returned",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/artifact.go#L149-L181 |
20,238 | hashicorp/atlas-go | v1/artifact.go | ArtifactFileURL | func (c *Client) ArtifactFileURL(av *ArtifactVersion) (*url.URL, error) {
if !av.File {
return nil, nil
}
u := *c.URL
u.Path = fmt.Sprintf("/api/v1/artifacts/%s/%s/%s/%d/file",
av.User, av.Name, av.Type, av.Version)
return &u, nil
} | go | func (c *Client) ArtifactFileURL(av *ArtifactVersion) (*url.URL, error) {
if !av.File {
return nil, nil
}
u := *c.URL
u.Path = fmt.Sprintf("/api/v1/artifacts/%s/%s/%s/%d/file",
av.User, av.Name, av.Type, av.Version)
return &u, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ArtifactFileURL",
"(",
"av",
"*",
"ArtifactVersion",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"if",
"!",
"av",
".",
"File",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"u",
":=",
... | // ArtifactFileURL is a helper method for getting the URL for an ArtifactVersion
// from the Client. | [
"ArtifactFileURL",
"is",
"a",
"helper",
"method",
"for",
"getting",
"the",
"URL",
"for",
"an",
"ArtifactVersion",
"from",
"the",
"Client",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/artifact.go#L185-L194 |
20,239 | hashicorp/atlas-go | v1/artifact.go | UploadArtifact | func (c *Client) UploadArtifact(opts *UploadArtifactOpts) (*ArtifactVersion, error) {
log.Printf("[INFO] uploading artifact: %s/%s (%s)", opts.User, opts.Name, opts.Type)
endpoint := fmt.Sprintf("/api/v1/artifacts/%s/%s/%s",
opts.User, opts.Name, opts.Type)
body, err := json.Marshal(opts)
if err != nil {
retu... | go | func (c *Client) UploadArtifact(opts *UploadArtifactOpts) (*ArtifactVersion, error) {
log.Printf("[INFO] uploading artifact: %s/%s (%s)", opts.User, opts.Name, opts.Type)
endpoint := fmt.Sprintf("/api/v1/artifacts/%s/%s/%s",
opts.User, opts.Name, opts.Type)
body, err := json.Marshal(opts)
if err != nil {
retu... | [
"func",
"(",
"c",
"*",
"Client",
")",
"UploadArtifact",
"(",
"opts",
"*",
"UploadArtifactOpts",
")",
"(",
"*",
"ArtifactVersion",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"opts",
".",
"User",
",",
"opts",
".",
"Name",
",",
... | // UploadArtifact streams the upload of a file on disk using the given
// UploadArtifactOpts. Any errors that occur are returned. | [
"UploadArtifact",
"streams",
"the",
"upload",
"of",
"a",
"file",
"on",
"disk",
"using",
"the",
"given",
"UploadArtifactOpts",
".",
"Any",
"errors",
"that",
"occur",
"are",
"returned",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/artifact.go#L198-L236 |
20,240 | hashicorp/atlas-go | v1/terraform.go | CreateTerraformConfigVersion | func (c *Client) CreateTerraformConfigVersion(
user string, name string,
version *TerraformConfigVersion,
data io.Reader, size int64) (int, error) {
log.Printf("[INFO] creating terraform configuration %s/%s", user, name)
endpoint := fmt.Sprintf(
"/api/v1/terraform/configurations/%s/%s/versions", user, name)
bo... | go | func (c *Client) CreateTerraformConfigVersion(
user string, name string,
version *TerraformConfigVersion,
data io.Reader, size int64) (int, error) {
log.Printf("[INFO] creating terraform configuration %s/%s", user, name)
endpoint := fmt.Sprintf(
"/api/v1/terraform/configurations/%s/%s/versions", user, name)
bo... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateTerraformConfigVersion",
"(",
"user",
"string",
",",
"name",
"string",
",",
"version",
"*",
"TerraformConfigVersion",
",",
"data",
"io",
".",
"Reader",
",",
"size",
"int64",
")",
"(",
"int",
",",
"error",
")",
... | // CreateTerraformConfigVersion creatse a new Terraform configuration
// versions and uploads a slug with it. | [
"CreateTerraformConfigVersion",
"creatse",
"a",
"new",
"Terraform",
"configuration",
"versions",
"and",
"uploads",
"a",
"slug",
"with",
"it",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/terraform.go#L57-L97 |
20,241 | hashicorp/atlas-go | v1/authentication.go | Login | func (c *Client) Login(username, password string) (string, error) {
log.Printf("[INFO] logging in user %s", username)
if len(username) == 0 {
return "", fmt.Errorf("client: missing username")
}
if len(password) == 0 {
return "", fmt.Errorf("client: missing password")
}
// Make a request
request, err := c.... | go | func (c *Client) Login(username, password string) (string, error) {
log.Printf("[INFO] logging in user %s", username)
if len(username) == 0 {
return "", fmt.Errorf("client: missing username")
}
if len(password) == 0 {
return "", fmt.Errorf("client: missing password")
}
// Make a request
request, err := c.... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Login",
"(",
"username",
",",
"password",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"username",
")",
"\n\n",
"if",
"len",
"(",
"username",
")",
"==",
"... | // Login accepts a username and password as string arguments. Both username and
// password must be non-nil, non-empty values. Atlas does not permit
// passwordless authentication.
//
// If authentication is unsuccessful, an error is returned with the body of the
// error containing the server's response.
//
// If auth... | [
"Login",
"accepts",
"a",
"username",
"and",
"password",
"as",
"string",
"arguments",
".",
"Both",
"username",
"and",
"password",
"must",
"be",
"non",
"-",
"nil",
"non",
"-",
"empty",
"values",
".",
"Atlas",
"does",
"not",
"permit",
"passwordless",
"authentic... | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/authentication.go#L19-L63 |
20,242 | hashicorp/atlas-go | v1/authentication.go | Verify | func (c *Client) Verify() error {
log.Printf("[INFO] verifying authentication")
request, err := c.Request("GET", "/api/v1/authenticate", nil)
if err != nil {
return err
}
_, err = checkResp(c.HTTPClient.Do(request))
return err
} | go | func (c *Client) Verify() error {
log.Printf("[INFO] verifying authentication")
request, err := c.Request("GET", "/api/v1/authenticate", nil)
if err != nil {
return err
}
_, err = checkResp(c.HTTPClient.Do(request))
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Verify",
"(",
")",
"error",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n\n",
"request",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
")",
"\n",
"if",
"err"... | // Verify verifies that authentication and communication with Atlas
// is properly functioning. | [
"Verify",
"verifies",
"that",
"authentication",
"and",
"communication",
"with",
"Atlas",
"is",
"properly",
"functioning",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/v1/authentication.go#L67-L77 |
20,243 | hashicorp/atlas-go | archive/vcs.go | vcsDetect | func vcsDetect(path string) (*VCS, error) {
dir := path
for {
for _, v := range VCSList {
for _, f := range v.Detect {
check := filepath.Join(dir, f)
if _, err := os.Stat(check); err == nil {
return v, nil
}
}
}
lastDir := dir
dir = filepath.Dir(dir)
if dir == lastDir {
break
}
... | go | func vcsDetect(path string) (*VCS, error) {
dir := path
for {
for _, v := range VCSList {
for _, f := range v.Detect {
check := filepath.Join(dir, f)
if _, err := os.Stat(check); err == nil {
return v, nil
}
}
}
lastDir := dir
dir = filepath.Dir(dir)
if dir == lastDir {
break
}
... | [
"func",
"vcsDetect",
"(",
"path",
"string",
")",
"(",
"*",
"VCS",
",",
"error",
")",
"{",
"dir",
":=",
"path",
"\n",
"for",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"VCSList",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"v",
".",
"Detect",
"{",
... | // vcsDetect detects the VCS that is used for path. | [
"vcsDetect",
"detects",
"the",
"VCS",
"that",
"is",
"used",
"for",
"path",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L79-L98 |
20,244 | hashicorp/atlas-go | archive/vcs.go | vcsPreflight | func vcsPreflight(path string) error {
vcs, err := vcsDetect(path)
if err != nil {
return fmt.Errorf("error detecting VCS: %s", err)
}
if vcs.Preflight != nil {
return vcs.Preflight(path)
}
return nil
} | go | func vcsPreflight(path string) error {
vcs, err := vcsDetect(path)
if err != nil {
return fmt.Errorf("error detecting VCS: %s", err)
}
if vcs.Preflight != nil {
return vcs.Preflight(path)
}
return nil
} | [
"func",
"vcsPreflight",
"(",
"path",
"string",
")",
"error",
"{",
"vcs",
",",
"err",
":=",
"vcsDetect",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"i... | // vcsPreflight returns the metadata for the VCS directory path. | [
"vcsPreflight",
"returns",
"the",
"metadata",
"for",
"the",
"VCS",
"directory",
"path",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L101-L112 |
20,245 | hashicorp/atlas-go | archive/vcs.go | vcsFiles | func vcsFiles(path string) ([]string, error) {
vcs, err := vcsDetect(path)
if err != nil {
return nil, fmt.Errorf("error detecting VCS: %s", err)
}
if vcs.Files != nil {
return vcs.Files(path)
}
return nil, nil
} | go | func vcsFiles(path string) ([]string, error) {
vcs, err := vcsDetect(path)
if err != nil {
return nil, fmt.Errorf("error detecting VCS: %s", err)
}
if vcs.Files != nil {
return vcs.Files(path)
}
return nil, nil
} | [
"func",
"vcsFiles",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"vcs",
",",
"err",
":=",
"vcsDetect",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
... | // vcsFiles returns the files for the VCS directory path. | [
"vcsFiles",
"returns",
"the",
"files",
"for",
"the",
"VCS",
"directory",
"path",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L115-L126 |
20,246 | hashicorp/atlas-go | archive/vcs.go | vcsFilesCmd | func vcsFilesCmd(args ...string) VCSFilesFunc {
return func(path string) ([]string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command(args[0], args[1:]...)
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf(
"error executing ... | go | func vcsFilesCmd(args ...string) VCSFilesFunc {
return func(path string) ([]string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command(args[0], args[1:]...)
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf(
"error executing ... | [
"func",
"vcsFilesCmd",
"(",
"args",
"...",
"string",
")",
"VCSFilesFunc",
"{",
"return",
"func",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"stderr",
",",
"stdout",
"bytes",
".",
"Buffer",
"\n\n",
"cmd",
":=",
... | // vcsFilesCmd creates a Files-compatible function that reads the files
// by executing the command in the repository path and returning each
// line in stdout. | [
"vcsFilesCmd",
"creates",
"a",
"Files",
"-",
"compatible",
"function",
"that",
"reads",
"the",
"files",
"by",
"executing",
"the",
"command",
"in",
"the",
"repository",
"path",
"and",
"returning",
"each",
"line",
"in",
"stdout",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L131-L160 |
20,247 | hashicorp/atlas-go | archive/vcs.go | vcsTrimCmd | func vcsTrimCmd(f VCSFilesFunc) VCSFilesFunc {
return func(path string) ([]string, error) {
absPath, err := filepath.Abs(path)
if err != nil {
return nil, fmt.Errorf(
"error expanding VCS path: %s", err)
}
// Now that we have the root path, get the inner files
fs, err := f(path)
if err != nil {
... | go | func vcsTrimCmd(f VCSFilesFunc) VCSFilesFunc {
return func(path string) ([]string, error) {
absPath, err := filepath.Abs(path)
if err != nil {
return nil, fmt.Errorf(
"error expanding VCS path: %s", err)
}
// Now that we have the root path, get the inner files
fs, err := f(path)
if err != nil {
... | [
"func",
"vcsTrimCmd",
"(",
"f",
"VCSFilesFunc",
")",
"VCSFilesFunc",
"{",
"return",
"func",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"absPath",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"path",
")",
"\n",
"if"... | // vcsTrimCmd trims the prefix from the paths returned by another VCSFilesFunc.
// This should be used to wrap another function if the return value is known
// to have full paths rather than relative paths | [
"vcsTrimCmd",
"trims",
"the",
"prefix",
"from",
"the",
"paths",
"returned",
"by",
"another",
"VCSFilesFunc",
".",
"This",
"should",
"be",
"used",
"to",
"wrap",
"another",
"function",
"if",
"the",
"return",
"value",
"is",
"known",
"to",
"have",
"full",
"paths... | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L165-L197 |
20,248 | hashicorp/atlas-go | archive/vcs.go | vcsMetadata | func vcsMetadata(path string) (map[string]string, error) {
vcs, err := vcsDetect(path)
if err != nil {
return nil, fmt.Errorf("error detecting VCS: %s", err)
}
if vcs.Metadata != nil {
return vcs.Metadata(path)
}
return nil, nil
} | go | func vcsMetadata(path string) (map[string]string, error) {
vcs, err := vcsDetect(path)
if err != nil {
return nil, fmt.Errorf("error detecting VCS: %s", err)
}
if vcs.Metadata != nil {
return vcs.Metadata(path)
}
return nil, nil
} | [
"func",
"vcsMetadata",
"(",
"path",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"vcs",
",",
"err",
":=",
"vcsDetect",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"E... | // vcsMetadata returns the metadata for the VCS directory path. | [
"vcsMetadata",
"returns",
"the",
"metadata",
"for",
"the",
"VCS",
"directory",
"path",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L200-L211 |
20,249 | hashicorp/atlas-go | archive/vcs.go | gitBranch | func gitBranch(path string) (string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "symbolic-ref", "--short", "HEAD")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
if strings.Contains(stderr.String(), ignorableDetachedHeadError) {
return "",... | go | func gitBranch(path string) (string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "symbolic-ref", "--short", "HEAD")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
if strings.Contains(stderr.String(), ignorableDetachedHeadError) {
return "",... | [
"func",
"gitBranch",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"stderr",
",",
"stdout",
"bytes",
".",
"Buffer",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"... | // gitBranch gets and returns the current git branch for the Git repository
// at the given path. It is assumed that the VCS is git. | [
"gitBranch",
"gets",
"and",
"returns",
"the",
"current",
"git",
"branch",
"for",
"the",
"Git",
"repository",
"at",
"the",
"given",
"path",
".",
"It",
"is",
"assumed",
"that",
"the",
"VCS",
"is",
"git",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L217-L237 |
20,250 | hashicorp/atlas-go | archive/vcs.go | gitCommit | func gitCommit(path string) (string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "log", "-n1", "--pretty=format:%H")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return "", fmt.Errorf("error getting git commit: %s\nstdout: %s\nstderr: %s",
... | go | func gitCommit(path string) (string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "log", "-n1", "--pretty=format:%H")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return "", fmt.Errorf("error getting git commit: %s\nstdout: %s\nstderr: %s",
... | [
"func",
"gitCommit",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"stderr",
",",
"stdout",
"bytes",
".",
"Buffer",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"... | // gitCommit gets the SHA of the latest commit for the Git repository at the
// given path. It is assumed that the VCS is git. | [
"gitCommit",
"gets",
"the",
"SHA",
"of",
"the",
"latest",
"commit",
"for",
"the",
"Git",
"repository",
"at",
"the",
"given",
"path",
".",
"It",
"is",
"assumed",
"that",
"the",
"VCS",
"is",
"git",
"."
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L241-L256 |
20,251 | hashicorp/atlas-go | archive/vcs.go | gitRemotes | func gitRemotes(path string) (map[string]string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "remote", "-v")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf("error getting git remotes: %s\nstdout: %s\nstderr: %s",
err,... | go | func gitRemotes(path string) (map[string]string, error) {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "remote", "-v")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf("error getting git remotes: %s\nstdout: %s\nstderr: %s",
err,... | [
"func",
"gitRemotes",
"(",
"path",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"var",
"stderr",
",",
"stdout",
"bytes",
".",
"Buffer",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"... | // gitRemotes gets and returns a map of all remotes for the Git repository. The
// map key is the name of the remote of the format "remote.NAME" and the value
// is the endpoint for the remote. It is assumed that the VCS is git. | [
"gitRemotes",
"gets",
"and",
"returns",
"a",
"map",
"of",
"all",
"remotes",
"for",
"the",
"Git",
"repository",
".",
"The",
"map",
"key",
"is",
"the",
"name",
"of",
"the",
"remote",
"of",
"the",
"format",
"remote",
".",
"NAME",
"and",
"the",
"value",
"i... | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L261-L293 |
20,252 | hashicorp/atlas-go | archive/vcs.go | gitPreflight | func gitPreflight(path string) error {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "--version")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("error getting git version: %s\nstdout: %s\nstderr: %s",
err, stdout.String(), stderr.St... | go | func gitPreflight(path string) error {
var stderr, stdout bytes.Buffer
cmd := exec.Command("git", "--version")
cmd.Dir = path
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("error getting git version: %s\nstdout: %s\nstderr: %s",
err, stdout.String(), stderr.St... | [
"func",
"gitPreflight",
"(",
"path",
"string",
")",
"error",
"{",
"var",
"stderr",
",",
"stdout",
"bytes",
".",
"Buffer",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"Dir",
"=",
"path",
"\n"... | // gitPreflight is the pre-flight command that runs for Git-based VCSs | [
"gitPreflight",
"is",
"the",
"pre",
"-",
"flight",
"command",
"that",
"runs",
"for",
"Git",
"-",
"based",
"VCSs"
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L296-L332 |
20,253 | hashicorp/atlas-go | archive/vcs.go | gitMetadata | func gitMetadata(path string) (map[string]string, error) {
// Future-self note: Git is NOT threadsafe, so we cannot run these
// operations in go routines or else you're going to have a really really
// bad day and Panda.State == "Sad" :(
branch, err := gitBranch(path)
if err != nil {
return nil, err
}
commi... | go | func gitMetadata(path string) (map[string]string, error) {
// Future-self note: Git is NOT threadsafe, so we cannot run these
// operations in go routines or else you're going to have a really really
// bad day and Panda.State == "Sad" :(
branch, err := gitBranch(path)
if err != nil {
return nil, err
}
commi... | [
"func",
"gitMetadata",
"(",
"path",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"// Future-self note: Git is NOT threadsafe, so we cannot run these",
"// operations in go routines or else you're going to have a really really",
"// bad day and ... | // gitMetadata is the function to parse and return Git metadata | [
"gitMetadata",
"is",
"the",
"function",
"to",
"parse",
"and",
"return",
"Git",
"metadata"
] | 8261ea0801056858f57a58ee6ce37b9365a78ce9 | https://github.com/hashicorp/atlas-go/blob/8261ea0801056858f57a58ee6ce37b9365a78ce9/archive/vcs.go#L335-L365 |
20,254 | gojuno/minimock | mock_controller.go | RegisterMocker | func (c *Controller) RegisterMocker(m Mocker) {
c.Lock()
c.mockers = append(c.mockers, m)
c.Unlock()
} | go | func (c *Controller) RegisterMocker(m Mocker) {
c.Lock()
c.mockers = append(c.mockers, m)
c.Unlock()
} | [
"func",
"(",
"c",
"*",
"Controller",
")",
"RegisterMocker",
"(",
"m",
"Mocker",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"c",
".",
"mockers",
"=",
"append",
"(",
"c",
".",
"mockers",
",",
"m",
")",
"\n",
"c",
".",
"Unlock",
"(",
")",
"\n",
... | //RegisterMocker puts mocker to the list of controller mockers | [
"RegisterMocker",
"puts",
"mocker",
"to",
"the",
"list",
"of",
"controller",
"mockers"
] | 31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e | https://github.com/gojuno/minimock/blob/31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e/mock_controller.go#L50-L54 |
20,255 | gojuno/minimock | mock_controller.go | Finish | func (c *Controller) Finish() {
c.Lock()
for _, m := range c.mockers {
m.MinimockFinish()
}
c.Unlock()
} | go | func (c *Controller) Finish() {
c.Lock()
for _, m := range c.mockers {
m.MinimockFinish()
}
c.Unlock()
} | [
"func",
"(",
"c",
"*",
"Controller",
")",
"Finish",
"(",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"c",
".",
"mockers",
"{",
"m",
".",
"MinimockFinish",
"(",
")",
"\n",
"}",
"\n",
"c",
".",
"Unlock",
"("... | //Finish calls to MinimockFinish method for all registered mockers | [
"Finish",
"calls",
"to",
"MinimockFinish",
"method",
"for",
"all",
"registered",
"mockers"
] | 31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e | https://github.com/gojuno/minimock/blob/31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e/mock_controller.go#L57-L63 |
20,256 | gojuno/minimock | mock_controller.go | Wait | func (c *Controller) Wait(d time.Duration) {
wg := sync.WaitGroup{}
wg.Add(len(c.mockers))
for _, m := range c.mockers {
go func(m Mocker) {
defer wg.Done()
m.MinimockWait(d)
}(m)
}
wg.Wait()
} | go | func (c *Controller) Wait(d time.Duration) {
wg := sync.WaitGroup{}
wg.Add(len(c.mockers))
for _, m := range c.mockers {
go func(m Mocker) {
defer wg.Done()
m.MinimockWait(d)
}(m)
}
wg.Wait()
} | [
"func",
"(",
"c",
"*",
"Controller",
")",
"Wait",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"wg",
":=",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"wg",
".",
"Add",
"(",
"len",
"(",
"c",
".",
"mockers",
")",
")",
"\n",
"for",
"_",
",",
"m",... | //Wait calls to MinimockWait method for all registered mockers | [
"Wait",
"calls",
"to",
"MinimockWait",
"method",
"for",
"all",
"registered",
"mockers"
] | 31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e | https://github.com/gojuno/minimock/blob/31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e/mock_controller.go#L66-L77 |
20,257 | gojuno/minimock | camel_to_snake.go | CamelToSnake | func CamelToSnake(s string) string {
b := buffer{
r: make([]byte, 0, len(s)),
}
var m rune
var w bool
for _, ch := range s {
if unicode.IsUpper(ch) {
if m != 0 {
if !w {
b.indent()
w = true
}
b.write(m)
}
m = unicode.ToLower(ch)
} else {
if m != 0 {
b.indent()
b.writ... | go | func CamelToSnake(s string) string {
b := buffer{
r: make([]byte, 0, len(s)),
}
var m rune
var w bool
for _, ch := range s {
if unicode.IsUpper(ch) {
if m != 0 {
if !w {
b.indent()
w = true
}
b.write(m)
}
m = unicode.ToLower(ch)
} else {
if m != 0 {
b.indent()
b.writ... | [
"func",
"CamelToSnake",
"(",
"s",
"string",
")",
"string",
"{",
"b",
":=",
"buffer",
"{",
"r",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"len",
"(",
"s",
")",
")",
",",
"}",
"\n",
"var",
"m",
"rune",
"\n",
"var",
"w",
"bool",
"\n",
... | // CamelToSnake transforms strings from CamelCase to snake_case | [
"CamelToSnake",
"transforms",
"strings",
"from",
"CamelCase",
"to",
"snake_case"
] | 31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e | https://github.com/gojuno/minimock/blob/31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e/camel_to_snake.go#L29-L62 |
20,258 | gojuno/minimock | cmd/minimock/minimock.go | checkDuplicateOutputFiles | func checkDuplicateOutputFiles(fileNames []string) error {
for i := range fileNames {
ok, err := isGoFile(fileNames[i])
if err != nil {
return err
}
if !ok {
continue
}
ipath, err := filepath.Abs(fileNames[i])
if err != nil {
return err
}
for j := range fileNames {
jpath, err := filepa... | go | func checkDuplicateOutputFiles(fileNames []string) error {
for i := range fileNames {
ok, err := isGoFile(fileNames[i])
if err != nil {
return err
}
if !ok {
continue
}
ipath, err := filepath.Abs(fileNames[i])
if err != nil {
return err
}
for j := range fileNames {
jpath, err := filepa... | [
"func",
"checkDuplicateOutputFiles",
"(",
"fileNames",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"i",
":=",
"range",
"fileNames",
"{",
"ok",
",",
"err",
":=",
"isGoFile",
"(",
"fileNames",
"[",
"i",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // checkDuplicateOutputFiles finds first non-unique Go file | [
"checkDuplicateOutputFiles",
"finds",
"first",
"non",
"-",
"unique",
"Go",
"file"
] | 31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e | https://github.com/gojuno/minimock/blob/31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e/cmd/minimock/minimock.go#L309-L338 |
20,259 | gojuno/minimock | equal.go | Equal | func Equal(a, b interface{}) bool {
if a == nil && b == nil {
return a == b
}
return reflect.DeepEqual(a, b)
} | go | func Equal(a, b interface{}) bool {
if a == nil && b == nil {
return a == b
}
return reflect.DeepEqual(a, b)
} | [
"func",
"Equal",
"(",
"a",
",",
"b",
"interface",
"{",
"}",
")",
"bool",
"{",
"if",
"a",
"==",
"nil",
"&&",
"b",
"==",
"nil",
"{",
"return",
"a",
"==",
"b",
"\n",
"}",
"\n\n",
"return",
"reflect",
".",
"DeepEqual",
"(",
"a",
",",
"b",
")",
"\... | // Equal returns true if a equals b | [
"Equal",
"returns",
"true",
"if",
"a",
"equals",
"b"
] | 31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e | https://github.com/gojuno/minimock/blob/31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e/equal.go#L17-L23 |
20,260 | gojuno/minimock | equal.go | Diff | func Diff(e, a interface{}) string {
if e == nil || a == nil {
return ""
}
t := reflect.TypeOf(e)
k := t.Kind()
if reflect.TypeOf(a) != t {
return ""
}
if k == reflect.Ptr {
t = t.Elem()
k = t.Kind()
}
if k != reflect.Array && k != reflect.Map && k != reflect.Slice && k != reflect.Struct {
return... | go | func Diff(e, a interface{}) string {
if e == nil || a == nil {
return ""
}
t := reflect.TypeOf(e)
k := t.Kind()
if reflect.TypeOf(a) != t {
return ""
}
if k == reflect.Ptr {
t = t.Elem()
k = t.Kind()
}
if k != reflect.Array && k != reflect.Map && k != reflect.Slice && k != reflect.Struct {
return... | [
"func",
"Diff",
"(",
"e",
",",
"a",
"interface",
"{",
"}",
")",
"string",
"{",
"if",
"e",
"==",
"nil",
"||",
"a",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"t",
":=",
"reflect",
".",
"TypeOf",
"(",
"e",
")",
"\n",
"k",
":=",
... | // Diff returns unified diff of the textual representations of e and a | [
"Diff",
"returns",
"unified",
"diff",
"of",
"the",
"textual",
"representations",
"of",
"e",
"and",
"a"
] | 31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e | https://github.com/gojuno/minimock/blob/31e8b94eb68b6c2a9e6eca57dd63a0f2392bbf1e/equal.go#L26-L63 |
20,261 | p4tin/goaws | app/router/router.go | New | func New() http.Handler {
r := mux.NewRouter()
r.HandleFunc("/", actionHandler).Methods("GET", "POST")
r.HandleFunc("/{account}", actionHandler).Methods("GET", "POST")
r.HandleFunc("/queue/{queueName}", actionHandler).Methods("GET", "POST")
r.HandleFunc("/{account}/{queueName}", actionHandler).Methods("GET", "POS... | go | func New() http.Handler {
r := mux.NewRouter()
r.HandleFunc("/", actionHandler).Methods("GET", "POST")
r.HandleFunc("/{account}", actionHandler).Methods("GET", "POST")
r.HandleFunc("/queue/{queueName}", actionHandler).Methods("GET", "POST")
r.HandleFunc("/{account}/{queueName}", actionHandler).Methods("GET", "POS... | [
"func",
"New",
"(",
")",
"http",
".",
"Handler",
"{",
"r",
":=",
"mux",
".",
"NewRouter",
"(",
")",
"\n\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"actionHandler",
")",
".",
"Methods",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"r",
".... | // New returns a new router | [
"New",
"returns",
"a",
"new",
"router"
] | 8d635c3b676f0c0c92ed0c86f70ee7256a877ac7 | https://github.com/p4tin/goaws/blob/8d635c3b676f0c0c92ed0c86f70ee7256a877ac7/app/router/router.go#L17-L28 |
20,262 | p4tin/goaws | app/sns.go | IsSatisfiedBy | func (fp *FilterPolicy) IsSatisfiedBy(msgAttrs map[string]MessageAttributeValue) bool {
for policyAttrName, policyAttrValues := range *fp {
attrValue, ok := msgAttrs[policyAttrName]
if !ok {
return false // the attribute has to be present in the message
}
// String, String.Array, Number data-types are allo... | go | func (fp *FilterPolicy) IsSatisfiedBy(msgAttrs map[string]MessageAttributeValue) bool {
for policyAttrName, policyAttrValues := range *fp {
attrValue, ok := msgAttrs[policyAttrName]
if !ok {
return false // the attribute has to be present in the message
}
// String, String.Array, Number data-types are allo... | [
"func",
"(",
"fp",
"*",
"FilterPolicy",
")",
"IsSatisfiedBy",
"(",
"msgAttrs",
"map",
"[",
"string",
"]",
"MessageAttributeValue",
")",
"bool",
"{",
"for",
"policyAttrName",
",",
"policyAttrValues",
":=",
"range",
"*",
"fp",
"{",
"attrValue",
",",
"ok",
":="... | // Function checks if MessageAttributes passed to Topic satisfy FilterPolicy set by subscription | [
"Function",
"checks",
"if",
"MessageAttributes",
"passed",
"to",
"Topic",
"satisfy",
"FilterPolicy",
"set",
"by",
"subscription"
] | 8d635c3b676f0c0c92ed0c86f70ee7256a877ac7 | https://github.com/p4tin/goaws/blob/8d635c3b676f0c0c92ed0c86f70ee7256a877ac7/app/sns.go#L49-L69 |
20,263 | InVisionApp/go-health | examples/status-listener/dependency/dependency.go | shouldBreakThings | func (l *loki) shouldBreakThings() bool {
l.Lock()
defer l.Unlock()
l.callcount++
if l.callcount > 15 {
l.callcount = 0
return false
}
if l.callcount > 10 {
return true
}
return false
} | go | func (l *loki) shouldBreakThings() bool {
l.Lock()
defer l.Unlock()
l.callcount++
if l.callcount > 15 {
l.callcount = 0
return false
}
if l.callcount > 10 {
return true
}
return false
} | [
"func",
"(",
"l",
"*",
"loki",
")",
"shouldBreakThings",
"(",
")",
"bool",
"{",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"callcount",
"++",
"\n",
"if",
"l",
".",
"callcount",
">",
"15",
"{",
"l",
... | // this is just a function that will return true
// the last 5 out of every 15 times called | [
"this",
"is",
"just",
"a",
"function",
"that",
"will",
"return",
"true",
"the",
"last",
"5",
"out",
"of",
"every",
"15",
"times",
"called"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/examples/status-listener/dependency/dependency.go#L18-L31 |
20,264 | InVisionApp/go-health | examples/custom-checker-server/custom-checker-server.go | Status | func (c *customCheck) Status() (interface{}, error) {
// perform some sort of check
if false {
return nil, fmt.Errorf("Something major just broke")
}
// You can return additional information pertaining to the check as long
// as it can be JSON marshalled
return map[string]int{"foo": 123, "bar": 456}, nil
} | go | func (c *customCheck) Status() (interface{}, error) {
// perform some sort of check
if false {
return nil, fmt.Errorf("Something major just broke")
}
// You can return additional information pertaining to the check as long
// as it can be JSON marshalled
return map[string]int{"foo": 123, "bar": 456}, nil
} | [
"func",
"(",
"c",
"*",
"customCheck",
")",
"Status",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// perform some sort of check",
"if",
"false",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n... | // Satisfy the go-health.ICheckable interface | [
"Satisfy",
"the",
"go",
"-",
"health",
".",
"ICheckable",
"interface"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/examples/custom-checker-server/custom-checker-server.go#L45-L54 |
20,265 | InVisionApp/go-health | checkers/disk/disk_usage.go | Status | func (d *DiskUsage) Status() (interface{}, error) {
stats, err := disk.Usage(d.Config.Path)
if err != nil {
return nil, fmt.Errorf("Error getting disk usage: %v", err)
}
diskUsage := stats.UsedPercent
if diskUsage >= d.Config.CriticalThreshold {
return nil, fmt.Errorf("Critical: disk usage too high %.2f per... | go | func (d *DiskUsage) Status() (interface{}, error) {
stats, err := disk.Usage(d.Config.Path)
if err != nil {
return nil, fmt.Errorf("Error getting disk usage: %v", err)
}
diskUsage := stats.UsedPercent
if diskUsage >= d.Config.CriticalThreshold {
return nil, fmt.Errorf("Critical: disk usage too high %.2f per... | [
"func",
"(",
"d",
"*",
"DiskUsage",
")",
"Status",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"stats",
",",
"err",
":=",
"disk",
".",
"Usage",
"(",
"d",
".",
"Config",
".",
"Path",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
... | // Status is used for performing a diskusage check against a dependency; it satisfies
// the "ICheckable" interface. | [
"Status",
"is",
"used",
"for",
"performing",
"a",
"diskusage",
"check",
"against",
"a",
"dependency",
";",
"it",
"satisfies",
"the",
"ICheckable",
"interface",
"."
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/disk/disk_usage.go#L43-L61 |
20,266 | InVisionApp/go-health | health.go | New | func New() *Health {
return &Health{
Logger: log.NewSimple(),
configs: make([]*Config, 0),
states: make(map[string]State, 0),
runners: make(map[string]chan struct{}, 0),
active: newBool(),
statesLock: sync.Mutex{},
}
} | go | func New() *Health {
return &Health{
Logger: log.NewSimple(),
configs: make([]*Config, 0),
states: make(map[string]State, 0),
runners: make(map[string]chan struct{}, 0),
active: newBool(),
statesLock: sync.Mutex{},
}
} | [
"func",
"New",
"(",
")",
"*",
"Health",
"{",
"return",
"&",
"Health",
"{",
"Logger",
":",
"log",
".",
"NewSimple",
"(",
")",
",",
"configs",
":",
"make",
"(",
"[",
"]",
"*",
"Config",
",",
"0",
")",
",",
"states",
":",
"make",
"(",
"map",
"[",
... | // New returns a new instance of the Health struct. | [
"New",
"returns",
"a",
"new",
"instance",
"of",
"the",
"Health",
"struct",
"."
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L137-L146 |
20,267 | InVisionApp/go-health | health.go | AddCheck | func (h *Health) AddCheck(cfg *Config) error {
if h.active.val() {
return ErrNoAddCfgWhenActive
}
h.configs = append(h.configs, cfg)
return nil
} | go | func (h *Health) AddCheck(cfg *Config) error {
if h.active.val() {
return ErrNoAddCfgWhenActive
}
h.configs = append(h.configs, cfg)
return nil
} | [
"func",
"(",
"h",
"*",
"Health",
")",
"AddCheck",
"(",
"cfg",
"*",
"Config",
")",
"error",
"{",
"if",
"h",
".",
"active",
".",
"val",
"(",
")",
"{",
"return",
"ErrNoAddCfgWhenActive",
"\n",
"}",
"\n\n",
"h",
".",
"configs",
"=",
"append",
"(",
"h",... | // AddCheck is used for adding a single check definition to the current health
// instance. | [
"AddCheck",
"is",
"used",
"for",
"adding",
"a",
"single",
"check",
"definition",
"to",
"the",
"current",
"health",
"instance",
"."
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L167-L174 |
20,268 | InVisionApp/go-health | health.go | Stop | func (h *Health) Stop() error {
if !h.active.val() {
return ErrAlreadyStopped
}
for name, stop := range h.runners {
h.Logger.WithFields(log.Fields{"name": name}).Debug("Stopping checker")
close(stop)
}
// Reset runner map
h.runners = make(map[string]chan struct{}, 0)
// Reset states
h.safeResetStates()... | go | func (h *Health) Stop() error {
if !h.active.val() {
return ErrAlreadyStopped
}
for name, stop := range h.runners {
h.Logger.WithFields(log.Fields{"name": name}).Debug("Stopping checker")
close(stop)
}
// Reset runner map
h.runners = make(map[string]chan struct{}, 0)
// Reset states
h.safeResetStates()... | [
"func",
"(",
"h",
"*",
"Health",
")",
"Stop",
"(",
")",
"error",
"{",
"if",
"!",
"h",
".",
"active",
".",
"val",
"(",
")",
"{",
"return",
"ErrAlreadyStopped",
"\n",
"}",
"\n\n",
"for",
"name",
",",
"stop",
":=",
"range",
"h",
".",
"runners",
"{",... | // Stop will cause all of the running health checks to be stopped. Additionally,
// all existing check states will be reset. | [
"Stop",
"will",
"cause",
"all",
"of",
"the",
"running",
"health",
"checks",
"to",
"be",
"stopped",
".",
"Additionally",
"all",
"existing",
"check",
"states",
"will",
"be",
"reset",
"."
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L206-L223 |
20,269 | InVisionApp/go-health | health.go | Failed | func (h *Health) Failed() bool {
for _, val := range h.safeGetStates() {
if val.Fatal && val.isFailure() {
return true
}
}
return false
} | go | func (h *Health) Failed() bool {
for _, val := range h.safeGetStates() {
if val.Fatal && val.isFailure() {
return true
}
}
return false
} | [
"func",
"(",
"h",
"*",
"Health",
")",
"Failed",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"val",
":=",
"range",
"h",
".",
"safeGetStates",
"(",
")",
"{",
"if",
"val",
".",
"Fatal",
"&&",
"val",
".",
"isFailure",
"(",
")",
"{",
"return",
"true",
"... | // Failed will return the basic state of overall health. This should be used when
// details about the failure are not needed | [
"Failed",
"will",
"return",
"the",
"basic",
"state",
"of",
"overall",
"health",
".",
"This",
"should",
"be",
"used",
"when",
"details",
"about",
"the",
"failure",
"are",
"not",
"needed"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L239-L246 |
20,270 | InVisionApp/go-health | health.go | safeResetStates | func (h *Health) safeResetStates() {
h.statesLock.Lock()
defer h.statesLock.Unlock()
h.states = make(map[string]State, 0)
} | go | func (h *Health) safeResetStates() {
h.statesLock.Lock()
defer h.statesLock.Unlock()
h.states = make(map[string]State, 0)
} | [
"func",
"(",
"h",
"*",
"Health",
")",
"safeResetStates",
"(",
")",
"{",
"h",
".",
"statesLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"statesLock",
".",
"Unlock",
"(",
")",
"\n",
"h",
".",
"states",
"=",
"make",
"(",
"map",
"[",
"string... | // resets the states in a concurrency-safe manner | [
"resets",
"the",
"states",
"in",
"a",
"concurrency",
"-",
"safe",
"manner"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L302-L306 |
20,271 | InVisionApp/go-health | health.go | safeUpdateState | func (h *Health) safeUpdateState(stateEntry *State) {
// dispatch any status listeners
h.handleStatusListener(stateEntry)
// update states here
h.statesLock.Lock()
defer h.statesLock.Unlock()
h.states[stateEntry.Name] = *stateEntry
} | go | func (h *Health) safeUpdateState(stateEntry *State) {
// dispatch any status listeners
h.handleStatusListener(stateEntry)
// update states here
h.statesLock.Lock()
defer h.statesLock.Unlock()
h.states[stateEntry.Name] = *stateEntry
} | [
"func",
"(",
"h",
"*",
"Health",
")",
"safeUpdateState",
"(",
"stateEntry",
"*",
"State",
")",
"{",
"// dispatch any status listeners",
"h",
".",
"handleStatusListener",
"(",
"stateEntry",
")",
"\n\n",
"// update states here",
"h",
".",
"statesLock",
".",
"Lock",
... | // updates the check state in a concurrency-safe manner | [
"updates",
"the",
"check",
"state",
"in",
"a",
"concurrency",
"-",
"safe",
"manner"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L309-L318 |
20,272 | InVisionApp/go-health | health.go | safeGetStates | func (h *Health) safeGetStates() map[string]State {
h.statesLock.Lock()
defer h.statesLock.Unlock()
// deep copy h.states to avoid race
statesCopy := make(map[string]State, 0)
for k, v := range h.states {
statesCopy[k] = v
}
return statesCopy
} | go | func (h *Health) safeGetStates() map[string]State {
h.statesLock.Lock()
defer h.statesLock.Unlock()
// deep copy h.states to avoid race
statesCopy := make(map[string]State, 0)
for k, v := range h.states {
statesCopy[k] = v
}
return statesCopy
} | [
"func",
"(",
"h",
"*",
"Health",
")",
"safeGetStates",
"(",
")",
"map",
"[",
"string",
"]",
"State",
"{",
"h",
".",
"statesLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"statesLock",
".",
"Unlock",
"(",
")",
"\n\n",
"// deep copy h.states to a... | // get all states in a concurrency-safe manner | [
"get",
"all",
"states",
"in",
"a",
"concurrency",
"-",
"safe",
"manner"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L321-L333 |
20,273 | InVisionApp/go-health | health.go | handleStatusListener | func (h *Health) handleStatusListener(stateEntry *State) {
// get the previous state
h.statesLock.Lock()
prevState := h.states[stateEntry.Name]
h.statesLock.Unlock()
// state is failure
if stateEntry.isFailure() {
if !prevState.isFailure() {
// new failure: previous state was ok
if h.StatusListener != ni... | go | func (h *Health) handleStatusListener(stateEntry *State) {
// get the previous state
h.statesLock.Lock()
prevState := h.states[stateEntry.Name]
h.statesLock.Unlock()
// state is failure
if stateEntry.isFailure() {
if !prevState.isFailure() {
// new failure: previous state was ok
if h.StatusListener != ni... | [
"func",
"(",
"h",
"*",
"Health",
")",
"handleStatusListener",
"(",
"stateEntry",
"*",
"State",
")",
"{",
"// get the previous state",
"h",
".",
"statesLock",
".",
"Lock",
"(",
")",
"\n",
"prevState",
":=",
"h",
".",
"states",
"[",
"stateEntry",
".",
"Name"... | // if a status listener is attached | [
"if",
"a",
"status",
"listener",
"is",
"attached"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/health.go#L336-L364 |
20,274 | InVisionApp/go-health | checkers/redis/redis.go | Status | func (r *Redis) Status() (interface{}, error) {
if r.Config.Ping {
if _, err := r.client.Ping().Result(); err != nil {
return nil, fmt.Errorf("Ping failed: %v", err)
}
}
if r.Config.Set != nil {
err := r.client.Set(r.Config.Set.Key, r.Config.Set.Value, r.Config.Set.Expiration).Err()
if err != nil {
re... | go | func (r *Redis) Status() (interface{}, error) {
if r.Config.Ping {
if _, err := r.client.Ping().Result(); err != nil {
return nil, fmt.Errorf("Ping failed: %v", err)
}
}
if r.Config.Set != nil {
err := r.client.Set(r.Config.Set.Key, r.Config.Set.Value, r.Config.Set.Expiration).Err()
if err != nil {
re... | [
"func",
"(",
"r",
"*",
"Redis",
")",
"Status",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"r",
".",
"Config",
".",
"Ping",
"{",
"if",
"_",
",",
"err",
":=",
"r",
".",
"client",
".",
"Ping",
"(",
")",
".",
"Result",
... | // Status is used for performing a redis check against a dependency; it satisfies
// the "ICheckable" interface. | [
"Status",
"is",
"used",
"for",
"performing",
"a",
"redis",
"check",
"against",
"a",
"dependency",
";",
"it",
"satisfies",
"the",
"ICheckable",
"interface",
"."
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/redis/redis.go#L111-L146 |
20,275 | InVisionApp/go-health | checkers/reachable.go | NewReachableChecker | func NewReachableChecker(cfg *ReachableConfig) (*ReachableChecker, error) {
t := ReachableDefaultTimeout
if cfg.Timeout != 0 {
t = cfg.Timeout
}
d := net.DialTimeout
if cfg.Dialer != nil {
d = cfg.Dialer
}
n := ReachableDefaultNetwork
if cfg.Network != "" {
n = cfg.Network
}
r := &ReachableChecker{
di... | go | func NewReachableChecker(cfg *ReachableConfig) (*ReachableChecker, error) {
t := ReachableDefaultTimeout
if cfg.Timeout != 0 {
t = cfg.Timeout
}
d := net.DialTimeout
if cfg.Dialer != nil {
d = cfg.Dialer
}
n := ReachableDefaultNetwork
if cfg.Network != "" {
n = cfg.Network
}
r := &ReachableChecker{
di... | [
"func",
"NewReachableChecker",
"(",
"cfg",
"*",
"ReachableConfig",
")",
"(",
"*",
"ReachableChecker",
",",
"error",
")",
"{",
"t",
":=",
"ReachableDefaultTimeout",
"\n",
"if",
"cfg",
".",
"Timeout",
"!=",
"0",
"{",
"t",
"=",
"cfg",
".",
"Timeout",
"\n",
... | // NewReachableChecker creates a new reachable health checker | [
"NewReachableChecker",
"creates",
"a",
"new",
"reachable",
"health",
"checker"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/reachable.go#L65-L87 |
20,276 | InVisionApp/go-health | checkers/reachable.go | Status | func (r *ReachableChecker) Status() (interface{}, error) {
// We must provide a port so when a port is not set in the URL provided use
// the default port (80)
port := r.url.Port()
if len(port) == 0 {
port = ReachableDefaultPort
}
conn, err := r.dialer(r.network, r.url.Hostname()+":"+port, r.timeout)
if err !... | go | func (r *ReachableChecker) Status() (interface{}, error) {
// We must provide a port so when a port is not set in the URL provided use
// the default port (80)
port := r.url.Port()
if len(port) == 0 {
port = ReachableDefaultPort
}
conn, err := r.dialer(r.network, r.url.Hostname()+":"+port, r.timeout)
if err !... | [
"func",
"(",
"r",
"*",
"ReachableChecker",
")",
"Status",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// We must provide a port so when a port is not set in the URL provided use",
"// the default port (80)",
"port",
":=",
"r",
".",
"url",
".",
"Po... | // Status checks if the endpoint is reachable | [
"Status",
"checks",
"if",
"the",
"endpoint",
"is",
"reachable"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/reachable.go#L90-L108 |
20,277 | InVisionApp/go-health | checkers/http.go | Status | func (h *HTTP) Status() (interface{}, error) {
resp, err := h.do()
if err != nil {
return nil, err
}
defer resp.Body.Close()
// Check if StatusCode matches
if resp.StatusCode != h.Config.StatusCode {
return nil, fmt.Errorf("Received status code '%v' does not match expected status code '%v'",
resp.StatusCo... | go | func (h *HTTP) Status() (interface{}, error) {
resp, err := h.do()
if err != nil {
return nil, err
}
defer resp.Body.Close()
// Check if StatusCode matches
if resp.StatusCode != h.Config.StatusCode {
return nil, fmt.Errorf("Received status code '%v' does not match expected status code '%v'",
resp.StatusCo... | [
"func",
"(",
"h",
"*",
"HTTP",
")",
"Status",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"h",
".",
"do",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n... | // Status is used for performing an HTTP check against a dependency; it satisfies
// the "ICheckable" interface. | [
"Status",
"is",
"used",
"for",
"performing",
"an",
"HTTP",
"check",
"against",
"a",
"dependency",
";",
"it",
"satisfies",
"the",
"ICheckable",
"interface",
"."
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/http.go#L66-L93 |
20,278 | InVisionApp/go-health | checkers/sql.go | DefaultQueryHandler | func DefaultQueryHandler(rows *sql.Rows) (bool, error) {
defer rows.Close()
numRows := 0
for rows.Next() {
numRows++
}
return numRows == 1, nil
} | go | func DefaultQueryHandler(rows *sql.Rows) (bool, error) {
defer rows.Close()
numRows := 0
for rows.Next() {
numRows++
}
return numRows == 1, nil
} | [
"func",
"DefaultQueryHandler",
"(",
"rows",
"*",
"sql",
".",
"Rows",
")",
"(",
"bool",
",",
"error",
")",
"{",
"defer",
"rows",
".",
"Close",
"(",
")",
"\n\n",
"numRows",
":=",
"0",
"\n",
"for",
"rows",
".",
"Next",
"(",
")",
"{",
"numRows",
"++",
... | // DefaultQueryHandler is the default SQLQueryer result handler
// that assumes one row was returned from the passed query | [
"DefaultQueryHandler",
"is",
"the",
"default",
"SQLQueryer",
"result",
"handler",
"that",
"assumes",
"one",
"row",
"was",
"returned",
"from",
"the",
"passed",
"query"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/sql.go#L102-L111 |
20,279 | InVisionApp/go-health | checkers/sql.go | DefaultExecHandler | func DefaultExecHandler(result sql.Result) (bool, error) {
affectedRows, err := result.RowsAffected()
if err != nil {
return false, err
}
return affectedRows == int64(1), nil
} | go | func DefaultExecHandler(result sql.Result) (bool, error) {
affectedRows, err := result.RowsAffected()
if err != nil {
return false, err
}
return affectedRows == int64(1), nil
} | [
"func",
"DefaultExecHandler",
"(",
"result",
"sql",
".",
"Result",
")",
"(",
"bool",
",",
"error",
")",
"{",
"affectedRows",
",",
"err",
":=",
"result",
".",
"RowsAffected",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
... | // DefaultExecHandler is the default SQLExecer result handler
// that assumes one row was affected in the passed query | [
"DefaultExecHandler",
"is",
"the",
"default",
"SQLExecer",
"result",
"handler",
"that",
"assumes",
"one",
"row",
"was",
"affected",
"in",
"the",
"passed",
"query"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/sql.go#L115-L122 |
20,280 | InVisionApp/go-health | checkers/sql.go | validateSQLConfig | func validateSQLConfig(cfg *SQLConfig) error {
if cfg == nil {
return fmt.Errorf("config is required")
}
if cfg.Execer == nil && cfg.Queryer == nil && cfg.Pinger == nil {
return fmt.Errorf("one of Execer, Queryer, or Pinger is required in SQLConfig")
}
if (cfg.Execer != nil || cfg.Queryer != nil) && len(cfg.... | go | func validateSQLConfig(cfg *SQLConfig) error {
if cfg == nil {
return fmt.Errorf("config is required")
}
if cfg.Execer == nil && cfg.Queryer == nil && cfg.Pinger == nil {
return fmt.Errorf("one of Execer, Queryer, or Pinger is required in SQLConfig")
}
if (cfg.Execer != nil || cfg.Queryer != nil) && len(cfg.... | [
"func",
"validateSQLConfig",
"(",
"cfg",
"*",
"SQLConfig",
")",
"error",
"{",
"if",
"cfg",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"cfg",
".",
"Execer",
"==",
"nil",
"&&",
"cfg",
".",
"Querye... | // this makes sure the sql check is properly configured | [
"this",
"makes",
"sure",
"the",
"sql",
"check",
"is",
"properly",
"configured"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/sql.go#L125-L139 |
20,281 | InVisionApp/go-health | checkers/sql.go | Status | func (s *SQL) Status() (interface{}, error) {
if err := validateSQLConfig(s.Config); err != nil {
return nil, err
}
switch {
// check for SQLExecer first
case s.Config.Execer != nil:
// if the result handler is nil, use the default
if s.Config.ExecerResultHandler == nil {
s.Config.ExecerResultHandler = D... | go | func (s *SQL) Status() (interface{}, error) {
if err := validateSQLConfig(s.Config); err != nil {
return nil, err
}
switch {
// check for SQLExecer first
case s.Config.Execer != nil:
// if the result handler is nil, use the default
if s.Config.ExecerResultHandler == nil {
s.Config.ExecerResultHandler = D... | [
"func",
"(",
"s",
"*",
"SQL",
")",
"Status",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"err",
":=",
"validateSQLConfig",
"(",
"s",
".",
"Config",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}... | // Status is used for performing a database ping against a dependency; it satisfies
// the "ICheckable" interface. | [
"Status",
"is",
"used",
"for",
"performing",
"a",
"database",
"ping",
"against",
"a",
"dependency",
";",
"it",
"satisfies",
"the",
"ICheckable",
"interface",
"."
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/sql.go#L143-L170 |
20,282 | InVisionApp/go-health | checkers/sql.go | runExecer | func (s *SQL) runExecer() (interface{}, error) {
ctx := context.Background()
result, err := s.Config.Execer.ExecContext(ctx, s.Config.Query, s.Config.Params...)
if err != nil {
return nil, err
}
ok, err := s.Config.ExecerResultHandler(result)
if err != nil {
return nil, err
}
if !ok {
return nil, fmt.Er... | go | func (s *SQL) runExecer() (interface{}, error) {
ctx := context.Background()
result, err := s.Config.Execer.ExecContext(ctx, s.Config.Query, s.Config.Params...)
if err != nil {
return nil, err
}
ok, err := s.Config.ExecerResultHandler(result)
if err != nil {
return nil, err
}
if !ok {
return nil, fmt.Er... | [
"func",
"(",
"s",
"*",
"SQL",
")",
"runExecer",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"result",
",",
"err",
":=",
"s",
".",
"Config",
".",
"Execer",
".",
"ExecCont... | // This will run the execer from the Status func | [
"This",
"will",
"run",
"the",
"execer",
"from",
"the",
"Status",
"func"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/sql.go#L173-L190 |
20,283 | InVisionApp/go-health | checkers/sql.go | runQueryer | func (s *SQL) runQueryer() (interface{}, error) {
ctx := context.Background()
rows, err := s.Config.Queryer.QueryContext(ctx, s.Config.Query, s.Config.Params...)
if err != nil {
return nil, err
}
// the BYO result handler is responsible for closing the rows
ok, err := s.Config.QueryerResultHandler(rows)
if e... | go | func (s *SQL) runQueryer() (interface{}, error) {
ctx := context.Background()
rows, err := s.Config.Queryer.QueryContext(ctx, s.Config.Query, s.Config.Params...)
if err != nil {
return nil, err
}
// the BYO result handler is responsible for closing the rows
ok, err := s.Config.QueryerResultHandler(rows)
if e... | [
"func",
"(",
"s",
"*",
"SQL",
")",
"runQueryer",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"rows",
",",
"err",
":=",
"s",
".",
"Config",
".",
"Queryer",
".",
"QueryCon... | // This will run the queryer from the Status func | [
"This",
"will",
"run",
"the",
"queryer",
"from",
"the",
"Status",
"func"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/checkers/sql.go#L193-L212 |
20,284 | InVisionApp/go-health | examples/status-listener/service/service.go | HealthCheckRecovered | func (sl *HealthCheckStatusListener) HealthCheckRecovered(entry *health.State, recordedFailures int64, failureDurationSeconds float64) {
svcLogger.Printf("Recovering from %d contiguous errors, lasting %1.2f seconds: %+v", recordedFailures, failureDurationSeconds, entry)
} | go | func (sl *HealthCheckStatusListener) HealthCheckRecovered(entry *health.State, recordedFailures int64, failureDurationSeconds float64) {
svcLogger.Printf("Recovering from %d contiguous errors, lasting %1.2f seconds: %+v", recordedFailures, failureDurationSeconds, entry)
} | [
"func",
"(",
"sl",
"*",
"HealthCheckStatusListener",
")",
"HealthCheckRecovered",
"(",
"entry",
"*",
"health",
".",
"State",
",",
"recordedFailures",
"int64",
",",
"failureDurationSeconds",
"float64",
")",
"{",
"svcLogger",
".",
"Printf",
"(",
"\"",
"\"",
",",
... | // HealthCheckRecovered is triggered when a health check recovers | [
"HealthCheckRecovered",
"is",
"triggered",
"when",
"a",
"health",
"check",
"recovers"
] | 21e799eae2a99deb884177d7c34997ddb880cbba | https://github.com/InVisionApp/go-health/blob/21e799eae2a99deb884177d7c34997ddb880cbba/examples/status-listener/service/service.go#L26-L28 |
20,285 | go-playground/form | form_encoder.go | NewEncoder | func NewEncoder() *Encoder {
e := &Encoder{
tagName: "form",
mode: ModeImplicit,
structCache: newStructCacheMap(),
embedAnonymous: true,
}
e.dataPool = &sync.Pool{New: func() interface{} {
return &encoder{
e: e,
namespace: make([]byte, 0, 64),
}
}}
return e
} | go | func NewEncoder() *Encoder {
e := &Encoder{
tagName: "form",
mode: ModeImplicit,
structCache: newStructCacheMap(),
embedAnonymous: true,
}
e.dataPool = &sync.Pool{New: func() interface{} {
return &encoder{
e: e,
namespace: make([]byte, 0, 64),
}
}}
return e
} | [
"func",
"NewEncoder",
"(",
")",
"*",
"Encoder",
"{",
"e",
":=",
"&",
"Encoder",
"{",
"tagName",
":",
"\"",
"\"",
",",
"mode",
":",
"ModeImplicit",
",",
"structCache",
":",
"newStructCacheMap",
"(",
")",
",",
"embedAnonymous",
":",
"true",
",",
"}",
"\n... | // NewEncoder creates a new encoder instance with sane defaults | [
"NewEncoder",
"creates",
"a",
"new",
"encoder",
"instance",
"with",
"sane",
"defaults"
] | 1174b88a8ea5deef83b10a874c5074826931ab03 | https://github.com/go-playground/form/blob/1174b88a8ea5deef83b10a874c5074826931ab03/form_encoder.go#L56-L73 |
20,286 | go-playground/form | form_encoder.go | Encode | func (e *Encoder) Encode(v interface{}) (values url.Values, err error) {
val, kind := ExtractType(reflect.ValueOf(v))
if kind == reflect.Ptr || kind == reflect.Interface || kind == reflect.Invalid {
return nil, &InvalidEncodeError{reflect.TypeOf(v)}
}
enc := e.dataPool.Get().(*encoder)
enc.values = make(url.V... | go | func (e *Encoder) Encode(v interface{}) (values url.Values, err error) {
val, kind := ExtractType(reflect.ValueOf(v))
if kind == reflect.Ptr || kind == reflect.Interface || kind == reflect.Invalid {
return nil, &InvalidEncodeError{reflect.TypeOf(v)}
}
enc := e.dataPool.Get().(*encoder)
enc.values = make(url.V... | [
"func",
"(",
"e",
"*",
"Encoder",
")",
"Encode",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"values",
"url",
".",
"Values",
",",
"err",
"error",
")",
"{",
"val",
",",
"kind",
":=",
"ExtractType",
"(",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
")"... | // Encode encodes the given values and sets the corresponding struct values | [
"Encode",
"encodes",
"the",
"given",
"values",
"and",
"sets",
"the",
"corresponding",
"struct",
"values"
] | 1174b88a8ea5deef83b10a874c5074826931ab03 | https://github.com/go-playground/form/blob/1174b88a8ea5deef83b10a874c5074826931ab03/form_encoder.go#L117-L144 |
20,287 | go-playground/form | form_decoder.go | NewDecoder | func NewDecoder() *Decoder {
d := &Decoder{
tagName: "form",
mode: ModeImplicit,
structCache: newStructCacheMap(),
maxArraySize: 10000,
}
d.dataPool = &sync.Pool{New: func() interface{} {
return &decoder{
d: d,
namespace: make([]byte, 0, 64),
}
}}
return d
} | go | func NewDecoder() *Decoder {
d := &Decoder{
tagName: "form",
mode: ModeImplicit,
structCache: newStructCacheMap(),
maxArraySize: 10000,
}
d.dataPool = &sync.Pool{New: func() interface{} {
return &decoder{
d: d,
namespace: make([]byte, 0, 64),
}
}}
return d
} | [
"func",
"NewDecoder",
"(",
")",
"*",
"Decoder",
"{",
"d",
":=",
"&",
"Decoder",
"{",
"tagName",
":",
"\"",
"\"",
",",
"mode",
":",
"ModeImplicit",
",",
"structCache",
":",
"newStructCacheMap",
"(",
")",
",",
"maxArraySize",
":",
"10000",
",",
"}",
"\n\... | // NewDecoder creates a new decoder instance with sane defaults | [
"NewDecoder",
"creates",
"a",
"new",
"decoder",
"instance",
"with",
"sane",
"defaults"
] | 1174b88a8ea5deef83b10a874c5074826931ab03 | https://github.com/go-playground/form/blob/1174b88a8ea5deef83b10a874c5074826931ab03/form_decoder.go#L75-L92 |
20,288 | go-playground/form | util.go | ExtractType | func ExtractType(current reflect.Value) (reflect.Value, reflect.Kind) {
switch current.Kind() {
case reflect.Ptr:
if current.IsNil() {
return current, reflect.Ptr
}
return ExtractType(current.Elem())
case reflect.Interface:
if current.IsNil() {
return current, reflect.Interface
}
return Extra... | go | func ExtractType(current reflect.Value) (reflect.Value, reflect.Kind) {
switch current.Kind() {
case reflect.Ptr:
if current.IsNil() {
return current, reflect.Ptr
}
return ExtractType(current.Elem())
case reflect.Interface:
if current.IsNil() {
return current, reflect.Interface
}
return Extra... | [
"func",
"ExtractType",
"(",
"current",
"reflect",
".",
"Value",
")",
"(",
"reflect",
".",
"Value",
",",
"reflect",
".",
"Kind",
")",
"{",
"switch",
"current",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Ptr",
":",
"if",
"current",
".",
"IsNi... | // ExtractType gets the actual underlying type of field value.
// it is exposed for use within you Custom Functions | [
"ExtractType",
"gets",
"the",
"actual",
"underlying",
"type",
"of",
"field",
"value",
".",
"it",
"is",
"exposed",
"for",
"use",
"within",
"you",
"Custom",
"Functions"
] | 1174b88a8ea5deef83b10a874c5074826931ab03 | https://github.com/go-playground/form/blob/1174b88a8ea5deef83b10a874c5074826931ab03/util.go#L10-L32 |
20,289 | go-playground/form | util.go | hasValue | func hasValue(field reflect.Value) bool {
switch field.Kind() {
case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func:
return !field.IsNil()
default:
return field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface()
}
} | go | func hasValue(field reflect.Value) bool {
switch field.Kind() {
case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func:
return !field.IsNil()
default:
return field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface()
}
} | [
"func",
"hasValue",
"(",
"field",
"reflect",
".",
"Value",
")",
"bool",
"{",
"switch",
"field",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Slice",
",",
"reflect",
".",
"Map",
",",
"reflect",
".",
"Ptr",
",",
"reflect",
".",
"Interface",
","... | // hasValue determines if a reflect.Value is it's default value | [
"hasValue",
"determines",
"if",
"a",
"reflect",
".",
"Value",
"is",
"it",
"s",
"default",
"value"
] | 1174b88a8ea5deef83b10a874c5074826931ab03 | https://github.com/go-playground/form/blob/1174b88a8ea5deef83b10a874c5074826931ab03/util.go#L49-L56 |
20,290 | eknkc/amber | compiler.go | New | func New() *Compiler {
compiler := new(Compiler)
compiler.filename = ""
compiler.tempvarIndex = 0
compiler.PrettyPrint = true
compiler.Options = DefaultOptions
compiler.mixins = make(map[string]*parser.Mixin)
return compiler
} | go | func New() *Compiler {
compiler := new(Compiler)
compiler.filename = ""
compiler.tempvarIndex = 0
compiler.PrettyPrint = true
compiler.Options = DefaultOptions
compiler.mixins = make(map[string]*parser.Mixin)
return compiler
} | [
"func",
"New",
"(",
")",
"*",
"Compiler",
"{",
"compiler",
":=",
"new",
"(",
"Compiler",
")",
"\n",
"compiler",
".",
"filename",
"=",
"\"",
"\"",
"\n",
"compiler",
".",
"tempvarIndex",
"=",
"0",
"\n",
"compiler",
".",
"PrettyPrint",
"=",
"true",
"\n",
... | // New creates and initialize a new Compiler. | [
"New",
"creates",
"and",
"initialize",
"a",
"new",
"Compiler",
"."
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L69-L78 |
20,291 | eknkc/amber | compiler.go | MustCompile | func MustCompile(input string, options Options) *template.Template {
t, err := Compile(input, options)
if err != nil {
panic(err)
}
return t
} | go | func MustCompile(input string, options Options) *template.Template {
t, err := Compile(input, options)
if err != nil {
panic(err)
}
return t
} | [
"func",
"MustCompile",
"(",
"input",
"string",
",",
"options",
"Options",
")",
"*",
"template",
".",
"Template",
"{",
"t",
",",
"err",
":=",
"Compile",
"(",
"input",
",",
"options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
... | // MustCompile is the same as Compile, except the input is assumed error free. If else, panic. | [
"MustCompile",
"is",
"the",
"same",
"as",
"Compile",
"except",
"the",
"input",
"is",
"assumed",
"error",
"free",
".",
"If",
"else",
"panic",
"."
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L141-L147 |
20,292 | eknkc/amber | compiler.go | MustCompileFile | func MustCompileFile(filename string, options Options) *template.Template {
t, err := CompileFile(filename, options)
if err != nil {
panic(err)
}
return t
} | go | func MustCompileFile(filename string, options Options) *template.Template {
t, err := CompileFile(filename, options)
if err != nil {
panic(err)
}
return t
} | [
"func",
"MustCompileFile",
"(",
"filename",
"string",
",",
"options",
"Options",
")",
"*",
"template",
".",
"Template",
"{",
"t",
",",
"err",
":=",
"CompileFile",
"(",
"filename",
",",
"options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
... | // MustCompileFile is the same as CompileFile, except the input is assumed error free. If else, panic. | [
"MustCompileFile",
"is",
"the",
"same",
"as",
"CompileFile",
"except",
"the",
"input",
"is",
"assumed",
"error",
"free",
".",
"If",
"else",
"panic",
"."
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L164-L170 |
20,293 | eknkc/amber | compiler.go | MustCompileDir | func MustCompileDir(dirname string, dopt DirOptions, opt Options) map[string]*template.Template {
m, err := CompileDir(dirname, dopt, opt)
if err != nil {
panic(err)
}
return m
} | go | func MustCompileDir(dirname string, dopt DirOptions, opt Options) map[string]*template.Template {
m, err := CompileDir(dirname, dopt, opt)
if err != nil {
panic(err)
}
return m
} | [
"func",
"MustCompileDir",
"(",
"dirname",
"string",
",",
"dopt",
"DirOptions",
",",
"opt",
"Options",
")",
"map",
"[",
"string",
"]",
"*",
"template",
".",
"Template",
"{",
"m",
",",
"err",
":=",
"CompileDir",
"(",
"dirname",
",",
"dopt",
",",
"opt",
"... | // MustCompileDir is the same as CompileDir, except input is assumed error free. If else, panic. | [
"MustCompileDir",
"is",
"the",
"same",
"as",
"CompileDir",
"except",
"input",
"is",
"assumed",
"error",
"free",
".",
"If",
"else",
"panic",
"."
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L231-L237 |
20,294 | eknkc/amber | compiler.go | ParseData | func (c *Compiler) ParseData(input []byte, filename string) (err error) {
defer func() {
if r := recover(); r != nil {
err = errors.New(r.(string))
}
}()
parser, err := parser.ByteParser(input)
parser.SetFilename(filename)
if c.VirtualFilesystem != nil {
parser.SetVirtualFilesystem(c.VirtualFilesystem)
... | go | func (c *Compiler) ParseData(input []byte, filename string) (err error) {
defer func() {
if r := recover(); r != nil {
err = errors.New(r.(string))
}
}()
parser, err := parser.ByteParser(input)
parser.SetFilename(filename)
if c.VirtualFilesystem != nil {
parser.SetVirtualFilesystem(c.VirtualFilesystem)
... | [
"func",
"(",
"c",
"*",
"Compiler",
")",
"ParseData",
"(",
"input",
"[",
"]",
"byte",
",",
"filename",
"string",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{"... | // Parse given raw amber template bytes, and the filename that belongs with it | [
"Parse",
"given",
"raw",
"amber",
"template",
"bytes",
"and",
"the",
"filename",
"that",
"belongs",
"with",
"it"
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L258-L277 |
20,295 | eknkc/amber | compiler.go | ParseFile | func (c *Compiler) ParseFile(filename string) (err error) {
defer func() {
if r := recover(); r != nil {
err = errors.New(r.(string))
}
}()
p, err := parser.FileParser(filename)
if err != nil && c.VirtualFilesystem != nil {
p, err = parser.VirtualFileParser(filename, c.VirtualFilesystem)
}
if err != nil... | go | func (c *Compiler) ParseFile(filename string) (err error) {
defer func() {
if r := recover(); r != nil {
err = errors.New(r.(string))
}
}()
p, err := parser.FileParser(filename)
if err != nil && c.VirtualFilesystem != nil {
p, err = parser.VirtualFileParser(filename, c.VirtualFilesystem)
}
if err != nil... | [
"func",
"(",
"c",
"*",
"Compiler",
")",
"ParseFile",
"(",
"filename",
"string",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Ne... | // ParseFile parses the amber template file in given path. | [
"ParseFile",
"parses",
"the",
"amber",
"template",
"file",
"in",
"given",
"path",
"."
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L280-L298 |
20,296 | eknkc/amber | compiler.go | CompileWithName | func (c *Compiler) CompileWithName(name string) (*template.Template, error) {
return c.CompileWithTemplate(template.New(name))
} | go | func (c *Compiler) CompileWithName(name string) (*template.Template, error) {
return c.CompileWithTemplate(template.New(name))
} | [
"func",
"(",
"c",
"*",
"Compiler",
")",
"CompileWithName",
"(",
"name",
"string",
")",
"(",
"*",
"template",
".",
"Template",
",",
"error",
")",
"{",
"return",
"c",
".",
"CompileWithTemplate",
"(",
"template",
".",
"New",
"(",
"name",
")",
")",
"\n",
... | // CompileWithName is the same as Compile, but allows to specify a name for the template. | [
"CompileWithName",
"is",
"the",
"same",
"as",
"Compile",
"but",
"allows",
"to",
"specify",
"a",
"name",
"for",
"the",
"template",
"."
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L307-L309 |
20,297 | eknkc/amber | compiler.go | CompileWithTemplate | func (c *Compiler) CompileWithTemplate(t *template.Template) (*template.Template, error) {
data, err := c.CompileString()
if err != nil {
return nil, err
}
tpl, err := t.Funcs(FuncMap).Parse(data)
if err != nil {
return nil, err
}
return tpl, nil
} | go | func (c *Compiler) CompileWithTemplate(t *template.Template) (*template.Template, error) {
data, err := c.CompileString()
if err != nil {
return nil, err
}
tpl, err := t.Funcs(FuncMap).Parse(data)
if err != nil {
return nil, err
}
return tpl, nil
} | [
"func",
"(",
"c",
"*",
"Compiler",
")",
"CompileWithTemplate",
"(",
"t",
"*",
"template",
".",
"Template",
")",
"(",
"*",
"template",
".",
"Template",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"c",
".",
"CompileString",
"(",
")",
"\n\n",
"if"... | // CompileWithTemplate is the same as Compile but allows to specify a template. | [
"CompileWithTemplate",
"is",
"the",
"same",
"as",
"Compile",
"but",
"allows",
"to",
"specify",
"a",
"template",
"."
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/compiler.go#L312-L326 |
20,298 | eknkc/amber | parser/scanner.go | Next | func (s *scanner) Next() *token {
if s.readRaw {
s.readRaw = false
return s.NextRaw()
}
s.ensureBuffer()
if stashed := s.stash.Front(); stashed != nil {
tok := stashed.Value.(*token)
s.stash.Remove(stashed)
return tok
}
switch s.state {
case scnEOF:
if outdent := s.indentStack.Back(); outdent != n... | go | func (s *scanner) Next() *token {
if s.readRaw {
s.readRaw = false
return s.NextRaw()
}
s.ensureBuffer()
if stashed := s.stash.Front(); stashed != nil {
tok := stashed.Value.(*token)
s.stash.Remove(stashed)
return tok
}
switch s.state {
case scnEOF:
if outdent := s.indentStack.Back(); outdent != n... | [
"func",
"(",
"s",
"*",
"scanner",
")",
"Next",
"(",
")",
"*",
"token",
"{",
"if",
"s",
".",
"readRaw",
"{",
"s",
".",
"readRaw",
"=",
"false",
"\n",
"return",
"s",
".",
"NextRaw",
"(",
")",
"\n",
"}",
"\n\n",
"s",
".",
"ensureBuffer",
"(",
")",... | // Returns next token found in buffer | [
"Returns",
"next",
"token",
"found",
"in",
"buffer"
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/parser/scanner.go#L80-L173 |
20,299 | eknkc/amber | parser/scanner.go | ensureBuffer | func (s *scanner) ensureBuffer() {
if len(s.buffer) > 0 {
return
}
buf, err := s.reader.ReadString('\n')
if err != nil && err != io.EOF {
panic(err)
} else if err != nil && len(buf) == 0 {
s.state = scnEOF
} else {
// endline "LF only" or "\n" use Unix, Linux, modern MacOS X, FreeBSD, BeOS, RISC OS
if... | go | func (s *scanner) ensureBuffer() {
if len(s.buffer) > 0 {
return
}
buf, err := s.reader.ReadString('\n')
if err != nil && err != io.EOF {
panic(err)
} else if err != nil && len(buf) == 0 {
s.state = scnEOF
} else {
// endline "LF only" or "\n" use Unix, Linux, modern MacOS X, FreeBSD, BeOS, RISC OS
if... | [
"func",
"(",
"s",
"*",
"scanner",
")",
"ensureBuffer",
"(",
")",
"{",
"if",
"len",
"(",
"s",
".",
"buffer",
")",
">",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"buf",
",",
"err",
":=",
"s",
".",
"reader",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n\... | // Reads string into s.buffer | [
"Reads",
"string",
"into",
"s",
".",
"buffer"
] | cdade1c073850f4ffc70a829e31235ea6892853b | https://github.com/eknkc/amber/blob/cdade1c073850f4ffc70a829e31235ea6892853b/parser/scanner.go#L475-L501 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.