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
|
---|---|---|---|---|---|---|---|---|---|---|---|
146,900 | jackc/pgx | pgtype/pguint32.go | Set | func (dst *pguint32) Set(src interface{}) error {
switch value := src.(type) {
case int64:
if value < 0 {
return errors.Errorf("%d is less than minimum value for pguint32", value)
}
if value > math.MaxUint32 {
return errors.Errorf("%d is greater than maximum value for pguint32", value)
}
*dst = pguint32{Uint: uint32(value), Status: Present}
case uint32:
*dst = pguint32{Uint: value, Status: Present}
default:
return errors.Errorf("cannot convert %v to pguint32", value)
}
return nil
} | go | func (dst *pguint32) Set(src interface{}) error {
switch value := src.(type) {
case int64:
if value < 0 {
return errors.Errorf("%d is less than minimum value for pguint32", value)
}
if value > math.MaxUint32 {
return errors.Errorf("%d is greater than maximum value for pguint32", value)
}
*dst = pguint32{Uint: uint32(value), Status: Present}
case uint32:
*dst = pguint32{Uint: value, Status: Present}
default:
return errors.Errorf("cannot convert %v to pguint32", value)
}
return nil
} | [
"func",
"(",
"dst",
"*",
"pguint32",
")",
"Set",
"(",
"src",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"value",
":=",
"src",
".",
"(",
"type",
")",
"{",
"case",
"int64",
":",
"if",
"value",
"<",
"0",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n",
"if",
"value",
">",
"math",
".",
"MaxUint32",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n",
"*",
"dst",
"=",
"pguint32",
"{",
"Uint",
":",
"uint32",
"(",
"value",
")",
",",
"Status",
":",
"Present",
"}",
"\n",
"case",
"uint32",
":",
"*",
"dst",
"=",
"pguint32",
"{",
"Uint",
":",
"value",
",",
"Status",
":",
"Present",
"}",
"\n",
"default",
":",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Set converts from src to dst. Note that as pguint32 is not a general
// number type Set does not do automatic type conversion as other number
// types do. | [
"Set",
"converts",
"from",
"src",
"to",
"dst",
".",
"Note",
"that",
"as",
"pguint32",
"is",
"not",
"a",
"general",
"number",
"type",
"Set",
"does",
"not",
"do",
"automatic",
"type",
"conversion",
"as",
"other",
"number",
"types",
"do",
"."
]
| 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/pguint32.go#L23-L40 |
146,901 | jackc/pgx | pgtype/pguint32.go | AssignTo | func (src *pguint32) AssignTo(dst interface{}) error {
switch v := dst.(type) {
case *uint32:
if src.Status == Present {
*v = src.Uint
} else {
return errors.Errorf("cannot assign %v into %T", src, dst)
}
case **uint32:
if src.Status == Present {
n := src.Uint
*v = &n
} else {
*v = nil
}
}
return nil
} | go | func (src *pguint32) AssignTo(dst interface{}) error {
switch v := dst.(type) {
case *uint32:
if src.Status == Present {
*v = src.Uint
} else {
return errors.Errorf("cannot assign %v into %T", src, dst)
}
case **uint32:
if src.Status == Present {
n := src.Uint
*v = &n
} else {
*v = nil
}
}
return nil
} | [
"func",
"(",
"src",
"*",
"pguint32",
")",
"AssignTo",
"(",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"v",
":=",
"dst",
".",
"(",
"type",
")",
"{",
"case",
"*",
"uint32",
":",
"if",
"src",
".",
"Status",
"==",
"Present",
"{",
"*",
"v",
"=",
"src",
".",
"Uint",
"\n",
"}",
"else",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"src",
",",
"dst",
")",
"\n",
"}",
"\n",
"case",
"*",
"*",
"uint32",
":",
"if",
"src",
".",
"Status",
"==",
"Present",
"{",
"n",
":=",
"src",
".",
"Uint",
"\n",
"*",
"v",
"=",
"&",
"n",
"\n",
"}",
"else",
"{",
"*",
"v",
"=",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // AssignTo assigns from src to dst. Note that as pguint32 is not a general number
// type AssignTo does not do automatic type conversion as other number types do. | [
"AssignTo",
"assigns",
"from",
"src",
"to",
"dst",
".",
"Note",
"that",
"as",
"pguint32",
"is",
"not",
"a",
"general",
"number",
"type",
"AssignTo",
"does",
"not",
"do",
"automatic",
"type",
"conversion",
"as",
"other",
"number",
"types",
"do",
"."
]
| 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/pguint32.go#L55-L73 |
146,902 | jackc/pgx | stdlib/opendbpool.go | OpenDBFromPool | func OpenDBFromPool(pool *pgx.ConnPool, opts ...OptionOpenDBFromPool) *sql.DB {
c := poolConnector{
pool: pool,
driver: pgxDriver,
}
for _, opt := range opts {
opt(&c)
}
return sql.OpenDB(c)
} | go | func OpenDBFromPool(pool *pgx.ConnPool, opts ...OptionOpenDBFromPool) *sql.DB {
c := poolConnector{
pool: pool,
driver: pgxDriver,
}
for _, opt := range opts {
opt(&c)
}
return sql.OpenDB(c)
} | [
"func",
"OpenDBFromPool",
"(",
"pool",
"*",
"pgx",
".",
"ConnPool",
",",
"opts",
"...",
"OptionOpenDBFromPool",
")",
"*",
"sql",
".",
"DB",
"{",
"c",
":=",
"poolConnector",
"{",
"pool",
":",
"pool",
",",
"driver",
":",
"pgxDriver",
",",
"}",
"\n\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"&",
"c",
")",
"\n",
"}",
"\n\n",
"return",
"sql",
".",
"OpenDB",
"(",
"c",
")",
"\n",
"}"
]
| // OpenDBFromPool create a sql.DB connection from a pgx.ConnPool | [
"OpenDBFromPool",
"create",
"a",
"sql",
".",
"DB",
"connection",
"from",
"a",
"pgx",
".",
"ConnPool"
]
| 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/opendbpool.go#L24-L35 |
146,903 | jackc/pgx | pgtype/bytea.go | DecodeText | func (dst *Bytea) DecodeText(ci *ConnInfo, src []byte) error {
if src == nil {
*dst = Bytea{Status: Null}
return nil
}
if len(src) < 2 || src[0] != '\\' || src[1] != 'x' {
return errors.Errorf("invalid hex format")
}
buf := make([]byte, (len(src)-2)/2)
_, err := hex.Decode(buf, src[2:])
if err != nil {
return err
}
*dst = Bytea{Bytes: buf, Status: Present}
return nil
} | go | func (dst *Bytea) DecodeText(ci *ConnInfo, src []byte) error {
if src == nil {
*dst = Bytea{Status: Null}
return nil
}
if len(src) < 2 || src[0] != '\\' || src[1] != 'x' {
return errors.Errorf("invalid hex format")
}
buf := make([]byte, (len(src)-2)/2)
_, err := hex.Decode(buf, src[2:])
if err != nil {
return err
}
*dst = Bytea{Bytes: buf, Status: Present}
return nil
} | [
"func",
"(",
"dst",
"*",
"Bytea",
")",
"DecodeText",
"(",
"ci",
"*",
"ConnInfo",
",",
"src",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"src",
"==",
"nil",
"{",
"*",
"dst",
"=",
"Bytea",
"{",
"Status",
":",
"Null",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"src",
")",
"<",
"2",
"||",
"src",
"[",
"0",
"]",
"!=",
"'\\\\'",
"||",
"src",
"[",
"1",
"]",
"!=",
"'x'",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"(",
"len",
"(",
"src",
")",
"-",
"2",
")",
"/",
"2",
")",
"\n",
"_",
",",
"err",
":=",
"hex",
".",
"Decode",
"(",
"buf",
",",
"src",
"[",
"2",
":",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"dst",
"=",
"Bytea",
"{",
"Bytes",
":",
"buf",
",",
"Status",
":",
"Present",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
| // DecodeText only supports the hex format. This has been the default since
// PostgreSQL 9.0. | [
"DecodeText",
"only",
"supports",
"the",
"hex",
"format",
".",
"This",
"has",
"been",
"the",
"default",
"since",
"PostgreSQL",
"9",
".",
"0",
"."
]
| 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/bytea.go#L72-L90 |
146,904 | jackc/pgx | stdlib/opendb.go | OptionAfterConnect | func OptionAfterConnect(ac func(*pgx.Conn) error) OptionOpenDB {
return func(dc *connector) {
dc.AfterConnect = ac
}
} | go | func OptionAfterConnect(ac func(*pgx.Conn) error) OptionOpenDB {
return func(dc *connector) {
dc.AfterConnect = ac
}
} | [
"func",
"OptionAfterConnect",
"(",
"ac",
"func",
"(",
"*",
"pgx",
".",
"Conn",
")",
"error",
")",
"OptionOpenDB",
"{",
"return",
"func",
"(",
"dc",
"*",
"connector",
")",
"{",
"dc",
".",
"AfterConnect",
"=",
"ac",
"\n",
"}",
"\n",
"}"
]
| // OptionAfterConnect provide a callback for after connect. | [
"OptionAfterConnect",
"provide",
"a",
"callback",
"for",
"after",
"connect",
"."
]
| 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/opendb.go#L17-L21 |
146,905 | parnurzeal/gorequest | gorequest_client_go1.3.go | safeModifyHttpClient | func (s *SuperAgent) safeModifyHttpClient() {
if !s.isClone {
return
}
oldClient := s.Client
s.Client = &http.Client{}
s.Client.Jar = oldClient.Jar
s.Client.Transport = oldClient.Transport
s.Client.Timeout = oldClient.Timeout
s.Client.CheckRedirect = oldClient.CheckRedirect
} | go | func (s *SuperAgent) safeModifyHttpClient() {
if !s.isClone {
return
}
oldClient := s.Client
s.Client = &http.Client{}
s.Client.Jar = oldClient.Jar
s.Client.Transport = oldClient.Transport
s.Client.Timeout = oldClient.Timeout
s.Client.CheckRedirect = oldClient.CheckRedirect
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"safeModifyHttpClient",
"(",
")",
"{",
"if",
"!",
"s",
".",
"isClone",
"{",
"return",
"\n",
"}",
"\n",
"oldClient",
":=",
"s",
".",
"Client",
"\n",
"s",
".",
"Client",
"=",
"&",
"http",
".",
"Client",
"{",
"}",
"\n",
"s",
".",
"Client",
".",
"Jar",
"=",
"oldClient",
".",
"Jar",
"\n",
"s",
".",
"Client",
".",
"Transport",
"=",
"oldClient",
".",
"Transport",
"\n",
"s",
".",
"Client",
".",
"Timeout",
"=",
"oldClient",
".",
"Timeout",
"\n",
"s",
".",
"Client",
".",
"CheckRedirect",
"=",
"oldClient",
".",
"CheckRedirect",
"\n",
"}"
]
| // we don't want to mess up other clones when we modify the client..
// so unfortantely we need to create a new client | [
"we",
"don",
"t",
"want",
"to",
"mess",
"up",
"other",
"clones",
"when",
"we",
"modify",
"the",
"client",
"..",
"so",
"unfortantely",
"we",
"need",
"to",
"create",
"a",
"new",
"client"
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest_client_go1.3.go#L13-L23 |
146,906 | parnurzeal/gorequest | gorequest_transport_go1.7.go | safeModifyTransport | func (s *SuperAgent) safeModifyTransport() {
if !s.isClone {
return
}
oldTransport := s.Transport
s.Transport = &http.Transport{
Proxy: oldTransport.Proxy,
Dial: oldTransport.Dial,
DialTLS: oldTransport.DialTLS,
TLSClientConfig: oldTransport.TLSClientConfig,
TLSHandshakeTimeout: oldTransport.TLSHandshakeTimeout,
DisableKeepAlives: oldTransport.DisableKeepAlives,
DisableCompression: oldTransport.DisableCompression,
MaxIdleConns: oldTransport.MaxIdleConns,
MaxIdleConnsPerHost: oldTransport.MaxIdleConnsPerHost,
ResponseHeaderTimeout: oldTransport.ResponseHeaderTimeout,
ExpectContinueTimeout: oldTransport.ExpectContinueTimeout,
TLSNextProto: oldTransport.TLSNextProto,
// new in go1.7
DialContext: oldTransport.DialContext,
IdleConnTimeout: oldTransport.IdleConnTimeout,
MaxResponseHeaderBytes: oldTransport.MaxResponseHeaderBytes,
}
} | go | func (s *SuperAgent) safeModifyTransport() {
if !s.isClone {
return
}
oldTransport := s.Transport
s.Transport = &http.Transport{
Proxy: oldTransport.Proxy,
Dial: oldTransport.Dial,
DialTLS: oldTransport.DialTLS,
TLSClientConfig: oldTransport.TLSClientConfig,
TLSHandshakeTimeout: oldTransport.TLSHandshakeTimeout,
DisableKeepAlives: oldTransport.DisableKeepAlives,
DisableCompression: oldTransport.DisableCompression,
MaxIdleConns: oldTransport.MaxIdleConns,
MaxIdleConnsPerHost: oldTransport.MaxIdleConnsPerHost,
ResponseHeaderTimeout: oldTransport.ResponseHeaderTimeout,
ExpectContinueTimeout: oldTransport.ExpectContinueTimeout,
TLSNextProto: oldTransport.TLSNextProto,
// new in go1.7
DialContext: oldTransport.DialContext,
IdleConnTimeout: oldTransport.IdleConnTimeout,
MaxResponseHeaderBytes: oldTransport.MaxResponseHeaderBytes,
}
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"safeModifyTransport",
"(",
")",
"{",
"if",
"!",
"s",
".",
"isClone",
"{",
"return",
"\n",
"}",
"\n",
"oldTransport",
":=",
"s",
".",
"Transport",
"\n",
"s",
".",
"Transport",
"=",
"&",
"http",
".",
"Transport",
"{",
"Proxy",
":",
"oldTransport",
".",
"Proxy",
",",
"Dial",
":",
"oldTransport",
".",
"Dial",
",",
"DialTLS",
":",
"oldTransport",
".",
"DialTLS",
",",
"TLSClientConfig",
":",
"oldTransport",
".",
"TLSClientConfig",
",",
"TLSHandshakeTimeout",
":",
"oldTransport",
".",
"TLSHandshakeTimeout",
",",
"DisableKeepAlives",
":",
"oldTransport",
".",
"DisableKeepAlives",
",",
"DisableCompression",
":",
"oldTransport",
".",
"DisableCompression",
",",
"MaxIdleConns",
":",
"oldTransport",
".",
"MaxIdleConns",
",",
"MaxIdleConnsPerHost",
":",
"oldTransport",
".",
"MaxIdleConnsPerHost",
",",
"ResponseHeaderTimeout",
":",
"oldTransport",
".",
"ResponseHeaderTimeout",
",",
"ExpectContinueTimeout",
":",
"oldTransport",
".",
"ExpectContinueTimeout",
",",
"TLSNextProto",
":",
"oldTransport",
".",
"TLSNextProto",
",",
"// new in go1.7\r",
"DialContext",
":",
"oldTransport",
".",
"DialContext",
",",
"IdleConnTimeout",
":",
"oldTransport",
".",
"IdleConnTimeout",
",",
"MaxResponseHeaderBytes",
":",
"oldTransport",
".",
"MaxResponseHeaderBytes",
",",
"}",
"\n",
"}"
]
| // does a shallow clone of the transport | [
"does",
"a",
"shallow",
"clone",
"of",
"the",
"transport"
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest_transport_go1.7.go#L11-L34 |
146,907 | parnurzeal/gorequest | gorequest.go | New | func New() *SuperAgent {
cookiejarOptions := cookiejar.Options{
PublicSuffixList: publicsuffix.List,
}
jar, _ := cookiejar.New(&cookiejarOptions)
debug := os.Getenv("GOREQUEST_DEBUG") == "1"
s := &SuperAgent{
TargetType: TypeJSON,
Data: make(map[string]interface{}),
Header: http.Header{},
RawString: "",
SliceData: []interface{}{},
FormData: url.Values{},
QueryData: url.Values{},
FileData: make([]File, 0),
BounceToRawString: false,
Client: &http.Client{Jar: jar},
Transport: &http.Transport{},
Cookies: make([]*http.Cookie, 0),
Errors: nil,
BasicAuth: struct{ Username, Password string }{},
Debug: debug,
CurlCommand: false,
logger: log.New(os.Stderr, "[gorequest]", log.LstdFlags),
isClone: false,
}
// disable keep alives by default, see this issue https://github.com/parnurzeal/gorequest/issues/75
s.Transport.DisableKeepAlives = true
return s
} | go | func New() *SuperAgent {
cookiejarOptions := cookiejar.Options{
PublicSuffixList: publicsuffix.List,
}
jar, _ := cookiejar.New(&cookiejarOptions)
debug := os.Getenv("GOREQUEST_DEBUG") == "1"
s := &SuperAgent{
TargetType: TypeJSON,
Data: make(map[string]interface{}),
Header: http.Header{},
RawString: "",
SliceData: []interface{}{},
FormData: url.Values{},
QueryData: url.Values{},
FileData: make([]File, 0),
BounceToRawString: false,
Client: &http.Client{Jar: jar},
Transport: &http.Transport{},
Cookies: make([]*http.Cookie, 0),
Errors: nil,
BasicAuth: struct{ Username, Password string }{},
Debug: debug,
CurlCommand: false,
logger: log.New(os.Stderr, "[gorequest]", log.LstdFlags),
isClone: false,
}
// disable keep alives by default, see this issue https://github.com/parnurzeal/gorequest/issues/75
s.Transport.DisableKeepAlives = true
return s
} | [
"func",
"New",
"(",
")",
"*",
"SuperAgent",
"{",
"cookiejarOptions",
":=",
"cookiejar",
".",
"Options",
"{",
"PublicSuffixList",
":",
"publicsuffix",
".",
"List",
",",
"}",
"\n",
"jar",
",",
"_",
":=",
"cookiejar",
".",
"New",
"(",
"&",
"cookiejarOptions",
")",
"\n\n",
"debug",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"\n\n",
"s",
":=",
"&",
"SuperAgent",
"{",
"TargetType",
":",
"TypeJSON",
",",
"Data",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
",",
"Header",
":",
"http",
".",
"Header",
"{",
"}",
",",
"RawString",
":",
"\"",
"\"",
",",
"SliceData",
":",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
",",
"FormData",
":",
"url",
".",
"Values",
"{",
"}",
",",
"QueryData",
":",
"url",
".",
"Values",
"{",
"}",
",",
"FileData",
":",
"make",
"(",
"[",
"]",
"File",
",",
"0",
")",
",",
"BounceToRawString",
":",
"false",
",",
"Client",
":",
"&",
"http",
".",
"Client",
"{",
"Jar",
":",
"jar",
"}",
",",
"Transport",
":",
"&",
"http",
".",
"Transport",
"{",
"}",
",",
"Cookies",
":",
"make",
"(",
"[",
"]",
"*",
"http",
".",
"Cookie",
",",
"0",
")",
",",
"Errors",
":",
"nil",
",",
"BasicAuth",
":",
"struct",
"{",
"Username",
",",
"Password",
"string",
"}",
"{",
"}",
",",
"Debug",
":",
"debug",
",",
"CurlCommand",
":",
"false",
",",
"logger",
":",
"log",
".",
"New",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\"",
",",
"log",
".",
"LstdFlags",
")",
",",
"isClone",
":",
"false",
",",
"}",
"\n",
"// disable keep alives by default, see this issue https://github.com/parnurzeal/gorequest/issues/75",
"s",
".",
"Transport",
".",
"DisableKeepAlives",
"=",
"true",
"\n",
"return",
"s",
"\n",
"}"
]
| // Used to create a new SuperAgent object. | [
"Used",
"to",
"create",
"a",
"new",
"SuperAgent",
"object",
"."
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L99-L130 |
146,908 | parnurzeal/gorequest | gorequest.go | copyRetryable | func copyRetryable(old superAgentRetryable) superAgentRetryable {
newRetryable := old
newRetryable.RetryableStatus = make([]int, len(old.RetryableStatus))
for i := range old.RetryableStatus {
newRetryable.RetryableStatus[i] = old.RetryableStatus[i]
}
return newRetryable
} | go | func copyRetryable(old superAgentRetryable) superAgentRetryable {
newRetryable := old
newRetryable.RetryableStatus = make([]int, len(old.RetryableStatus))
for i := range old.RetryableStatus {
newRetryable.RetryableStatus[i] = old.RetryableStatus[i]
}
return newRetryable
} | [
"func",
"copyRetryable",
"(",
"old",
"superAgentRetryable",
")",
"superAgentRetryable",
"{",
"newRetryable",
":=",
"old",
"\n",
"newRetryable",
".",
"RetryableStatus",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"old",
".",
"RetryableStatus",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"old",
".",
"RetryableStatus",
"{",
"newRetryable",
".",
"RetryableStatus",
"[",
"i",
"]",
"=",
"old",
".",
"RetryableStatus",
"[",
"i",
"]",
"\n",
"}",
"\n",
"return",
"newRetryable",
"\n",
"}"
]
| // just need to change the array pointer? | [
"just",
"need",
"to",
"change",
"the",
"array",
"pointer?"
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L194-L201 |
146,909 | parnurzeal/gorequest | gorequest.go | SetCurlCommand | func (s *SuperAgent) SetCurlCommand(enable bool) *SuperAgent {
s.CurlCommand = enable
return s
} | go | func (s *SuperAgent) SetCurlCommand(enable bool) *SuperAgent {
s.CurlCommand = enable
return s
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"SetCurlCommand",
"(",
"enable",
"bool",
")",
"*",
"SuperAgent",
"{",
"s",
".",
"CurlCommand",
"=",
"enable",
"\n",
"return",
"s",
"\n",
"}"
]
| // Enable the curlcommand mode which display a CURL command line | [
"Enable",
"the",
"curlcommand",
"mode",
"which",
"display",
"a",
"CURL",
"command",
"line"
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L248-L251 |
146,910 | parnurzeal/gorequest | gorequest.go | SetDoNotClearSuperAgent | func (s *SuperAgent) SetDoNotClearSuperAgent(enable bool) *SuperAgent {
s.DoNotClearSuperAgent = enable
return s
} | go | func (s *SuperAgent) SetDoNotClearSuperAgent(enable bool) *SuperAgent {
s.DoNotClearSuperAgent = enable
return s
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"SetDoNotClearSuperAgent",
"(",
"enable",
"bool",
")",
"*",
"SuperAgent",
"{",
"s",
".",
"DoNotClearSuperAgent",
"=",
"enable",
"\n",
"return",
"s",
"\n",
"}"
]
| // Enable the DoNotClear mode for not clearing super agent and reuse for the next request | [
"Enable",
"the",
"DoNotClear",
"mode",
"for",
"not",
"clearing",
"super",
"agent",
"and",
"reuse",
"for",
"the",
"next",
"request"
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L254-L257 |
146,911 | parnurzeal/gorequest | gorequest.go | ClearSuperAgent | func (s *SuperAgent) ClearSuperAgent() {
if s.DoNotClearSuperAgent {
return
}
s.Url = ""
s.Method = ""
s.Header = http.Header{}
s.Data = make(map[string]interface{})
s.SliceData = []interface{}{}
s.FormData = url.Values{}
s.QueryData = url.Values{}
s.FileData = make([]File, 0)
s.BounceToRawString = false
s.RawString = ""
s.ForceType = ""
s.TargetType = TypeJSON
s.Cookies = make([]*http.Cookie, 0)
s.Errors = nil
} | go | func (s *SuperAgent) ClearSuperAgent() {
if s.DoNotClearSuperAgent {
return
}
s.Url = ""
s.Method = ""
s.Header = http.Header{}
s.Data = make(map[string]interface{})
s.SliceData = []interface{}{}
s.FormData = url.Values{}
s.QueryData = url.Values{}
s.FileData = make([]File, 0)
s.BounceToRawString = false
s.RawString = ""
s.ForceType = ""
s.TargetType = TypeJSON
s.Cookies = make([]*http.Cookie, 0)
s.Errors = nil
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"ClearSuperAgent",
"(",
")",
"{",
"if",
"s",
".",
"DoNotClearSuperAgent",
"{",
"return",
"\n",
"}",
"\n",
"s",
".",
"Url",
"=",
"\"",
"\"",
"\n",
"s",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"s",
".",
"Header",
"=",
"http",
".",
"Header",
"{",
"}",
"\n",
"s",
".",
"Data",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"s",
".",
"SliceData",
"=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"s",
".",
"FormData",
"=",
"url",
".",
"Values",
"{",
"}",
"\n",
"s",
".",
"QueryData",
"=",
"url",
".",
"Values",
"{",
"}",
"\n",
"s",
".",
"FileData",
"=",
"make",
"(",
"[",
"]",
"File",
",",
"0",
")",
"\n",
"s",
".",
"BounceToRawString",
"=",
"false",
"\n",
"s",
".",
"RawString",
"=",
"\"",
"\"",
"\n",
"s",
".",
"ForceType",
"=",
"\"",
"\"",
"\n",
"s",
".",
"TargetType",
"=",
"TypeJSON",
"\n",
"s",
".",
"Cookies",
"=",
"make",
"(",
"[",
"]",
"*",
"http",
".",
"Cookie",
",",
"0",
")",
"\n",
"s",
".",
"Errors",
"=",
"nil",
"\n",
"}"
]
| // Clear SuperAgent data for another new request. | [
"Clear",
"SuperAgent",
"data",
"for",
"another",
"new",
"request",
"."
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L265-L283 |
146,912 | parnurzeal/gorequest | gorequest.go | CustomMethod | func (s *SuperAgent) CustomMethod(method, targetUrl string) *SuperAgent {
switch method {
case POST:
return s.Post(targetUrl)
case GET:
return s.Get(targetUrl)
case HEAD:
return s.Head(targetUrl)
case PUT:
return s.Put(targetUrl)
case DELETE:
return s.Delete(targetUrl)
case PATCH:
return s.Patch(targetUrl)
case OPTIONS:
return s.Options(targetUrl)
default:
s.ClearSuperAgent()
s.Method = method
s.Url = targetUrl
s.Errors = nil
return s
}
} | go | func (s *SuperAgent) CustomMethod(method, targetUrl string) *SuperAgent {
switch method {
case POST:
return s.Post(targetUrl)
case GET:
return s.Get(targetUrl)
case HEAD:
return s.Head(targetUrl)
case PUT:
return s.Put(targetUrl)
case DELETE:
return s.Delete(targetUrl)
case PATCH:
return s.Patch(targetUrl)
case OPTIONS:
return s.Options(targetUrl)
default:
s.ClearSuperAgent()
s.Method = method
s.Url = targetUrl
s.Errors = nil
return s
}
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"CustomMethod",
"(",
"method",
",",
"targetUrl",
"string",
")",
"*",
"SuperAgent",
"{",
"switch",
"method",
"{",
"case",
"POST",
":",
"return",
"s",
".",
"Post",
"(",
"targetUrl",
")",
"\n",
"case",
"GET",
":",
"return",
"s",
".",
"Get",
"(",
"targetUrl",
")",
"\n",
"case",
"HEAD",
":",
"return",
"s",
".",
"Head",
"(",
"targetUrl",
")",
"\n",
"case",
"PUT",
":",
"return",
"s",
".",
"Put",
"(",
"targetUrl",
")",
"\n",
"case",
"DELETE",
":",
"return",
"s",
".",
"Delete",
"(",
"targetUrl",
")",
"\n",
"case",
"PATCH",
":",
"return",
"s",
".",
"Patch",
"(",
"targetUrl",
")",
"\n",
"case",
"OPTIONS",
":",
"return",
"s",
".",
"Options",
"(",
"targetUrl",
")",
"\n",
"default",
":",
"s",
".",
"ClearSuperAgent",
"(",
")",
"\n",
"s",
".",
"Method",
"=",
"method",
"\n",
"s",
".",
"Url",
"=",
"targetUrl",
"\n",
"s",
".",
"Errors",
"=",
"nil",
"\n",
"return",
"s",
"\n",
"}",
"\n",
"}"
]
| // Just a wrapper to initialize SuperAgent instance by method string | [
"Just",
"a",
"wrapper",
"to",
"initialize",
"SuperAgent",
"instance",
"by",
"method",
"string"
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L286-L309 |
146,913 | parnurzeal/gorequest | gorequest.go | RedirectPolicy | func (s *SuperAgent) RedirectPolicy(policy func(req Request, via []Request) error) *SuperAgent {
s.safeModifyHttpClient()
s.Client.CheckRedirect = func(r *http.Request, v []*http.Request) error {
vv := make([]Request, len(v))
for i, r := range v {
vv[i] = Request(r)
}
return policy(Request(r), vv)
}
return s
} | go | func (s *SuperAgent) RedirectPolicy(policy func(req Request, via []Request) error) *SuperAgent {
s.safeModifyHttpClient()
s.Client.CheckRedirect = func(r *http.Request, v []*http.Request) error {
vv := make([]Request, len(v))
for i, r := range v {
vv[i] = Request(r)
}
return policy(Request(r), vv)
}
return s
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"RedirectPolicy",
"(",
"policy",
"func",
"(",
"req",
"Request",
",",
"via",
"[",
"]",
"Request",
")",
"error",
")",
"*",
"SuperAgent",
"{",
"s",
".",
"safeModifyHttpClient",
"(",
")",
"\n",
"s",
".",
"Client",
".",
"CheckRedirect",
"=",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"v",
"[",
"]",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"vv",
":=",
"make",
"(",
"[",
"]",
"Request",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
",",
"r",
":=",
"range",
"v",
"{",
"vv",
"[",
"i",
"]",
"=",
"Request",
"(",
"r",
")",
"\n",
"}",
"\n",
"return",
"policy",
"(",
"Request",
"(",
"r",
")",
",",
"vv",
")",
"\n",
"}",
"\n",
"return",
"s",
"\n",
"}"
]
| // RedirectPolicy accepts a function to define how to handle redirects. If the
// policy function returns an error, the next Request is not made and the previous
// request is returned.
//
// The policy function's arguments are the Request about to be made and the
// past requests in order of oldest first. | [
"RedirectPolicy",
"accepts",
"a",
"function",
"to",
"define",
"how",
"to",
"handle",
"redirects",
".",
"If",
"the",
"policy",
"function",
"returns",
"an",
"error",
"the",
"next",
"Request",
"is",
"not",
"made",
"and",
"the",
"previous",
"request",
"is",
"returned",
".",
"The",
"policy",
"function",
"s",
"arguments",
"are",
"the",
"Request",
"about",
"to",
"be",
"made",
"and",
"the",
"past",
"requests",
"in",
"order",
"of",
"oldest",
"first",
"."
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L649-L659 |
146,914 | parnurzeal/gorequest | gorequest.go | EndStruct | func (s *SuperAgent) EndStruct(v interface{}, callback ...func(response Response, v interface{}, body []byte, errs []error)) (Response, []byte, []error) {
resp, body, errs := s.EndBytes()
if errs != nil {
return nil, body, errs
}
err := json.Unmarshal(body, &v)
if err != nil {
s.Errors = append(s.Errors, err)
return resp, body, s.Errors
}
respCallback := *resp
if len(callback) != 0 {
callback[0](&respCallback, v, body, s.Errors)
}
return resp, body, nil
} | go | func (s *SuperAgent) EndStruct(v interface{}, callback ...func(response Response, v interface{}, body []byte, errs []error)) (Response, []byte, []error) {
resp, body, errs := s.EndBytes()
if errs != nil {
return nil, body, errs
}
err := json.Unmarshal(body, &v)
if err != nil {
s.Errors = append(s.Errors, err)
return resp, body, s.Errors
}
respCallback := *resp
if len(callback) != 0 {
callback[0](&respCallback, v, body, s.Errors)
}
return resp, body, nil
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"EndStruct",
"(",
"v",
"interface",
"{",
"}",
",",
"callback",
"...",
"func",
"(",
"response",
"Response",
",",
"v",
"interface",
"{",
"}",
",",
"body",
"[",
"]",
"byte",
",",
"errs",
"[",
"]",
"error",
")",
")",
"(",
"Response",
",",
"[",
"]",
"byte",
",",
"[",
"]",
"error",
")",
"{",
"resp",
",",
"body",
",",
"errs",
":=",
"s",
".",
"EndBytes",
"(",
")",
"\n",
"if",
"errs",
"!=",
"nil",
"{",
"return",
"nil",
",",
"body",
",",
"errs",
"\n",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"body",
",",
"&",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"Errors",
"=",
"append",
"(",
"s",
".",
"Errors",
",",
"err",
")",
"\n",
"return",
"resp",
",",
"body",
",",
"s",
".",
"Errors",
"\n",
"}",
"\n",
"respCallback",
":=",
"*",
"resp",
"\n",
"if",
"len",
"(",
"callback",
")",
"!=",
"0",
"{",
"callback",
"[",
"0",
"]",
"(",
"&",
"respCallback",
",",
"v",
",",
"body",
",",
"s",
".",
"Errors",
")",
"\n",
"}",
"\n",
"return",
"resp",
",",
"body",
",",
"nil",
"\n",
"}"
]
| // EndStruct should be used when you want the body as a struct. The callbacks work the same way as with `End`, except that a struct is used instead of a string. | [
"EndStruct",
"should",
"be",
"used",
"when",
"you",
"want",
"the",
"body",
"as",
"a",
"struct",
".",
"The",
"callbacks",
"work",
"the",
"same",
"way",
"as",
"with",
"End",
"except",
"that",
"a",
"struct",
"is",
"used",
"instead",
"of",
"a",
"string",
"."
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L1124-L1139 |
146,915 | parnurzeal/gorequest | gorequest.go | AsCurlCommand | func (s *SuperAgent) AsCurlCommand() (string, error) {
req, err := s.MakeRequest()
if err != nil {
return "", err
}
cmd, err := http2curl.GetCurlCommand(req)
if err != nil {
return "", err
}
return cmd.String(), nil
} | go | func (s *SuperAgent) AsCurlCommand() (string, error) {
req, err := s.MakeRequest()
if err != nil {
return "", err
}
cmd, err := http2curl.GetCurlCommand(req)
if err != nil {
return "", err
}
return cmd.String(), nil
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"AsCurlCommand",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"s",
".",
"MakeRequest",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"cmd",
",",
"err",
":=",
"http2curl",
".",
"GetCurlCommand",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"cmd",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}"
]
| // AsCurlCommand returns a string representing the runnable `curl' command
// version of the request. | [
"AsCurlCommand",
"returns",
"a",
"string",
"representing",
"the",
"runnable",
"curl",
"command",
"version",
"of",
"the",
"request",
"."
]
| b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L1405-L1415 |
146,916 | yuin/gopher-lua | table.go | Len | func (tb *LTable) Len() int {
if tb.array == nil {
return 0
}
var prev LValue = LNil
for i := len(tb.array) - 1; i >= 0; i-- {
v := tb.array[i]
if prev == LNil && v != LNil {
return i + 1
}
prev = v
}
return 0
} | go | func (tb *LTable) Len() int {
if tb.array == nil {
return 0
}
var prev LValue = LNil
for i := len(tb.array) - 1; i >= 0; i-- {
v := tb.array[i]
if prev == LNil && v != LNil {
return i + 1
}
prev = v
}
return 0
} | [
"func",
"(",
"tb",
"*",
"LTable",
")",
"Len",
"(",
")",
"int",
"{",
"if",
"tb",
".",
"array",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"var",
"prev",
"LValue",
"=",
"LNil",
"\n",
"for",
"i",
":=",
"len",
"(",
"tb",
".",
"array",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"v",
":=",
"tb",
".",
"array",
"[",
"i",
"]",
"\n",
"if",
"prev",
"==",
"LNil",
"&&",
"v",
"!=",
"LNil",
"{",
"return",
"i",
"+",
"1",
"\n",
"}",
"\n",
"prev",
"=",
"v",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
]
| // Len returns length of this LTable. | [
"Len",
"returns",
"length",
"of",
"this",
"LTable",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/table.go#L50-L63 |
146,917 | yuin/gopher-lua | table.go | Append | func (tb *LTable) Append(value LValue) {
if value == LNil {
return
}
if tb.array == nil {
tb.array = make([]LValue, 0, defaultArrayCap)
}
tb.array = append(tb.array, value)
} | go | func (tb *LTable) Append(value LValue) {
if value == LNil {
return
}
if tb.array == nil {
tb.array = make([]LValue, 0, defaultArrayCap)
}
tb.array = append(tb.array, value)
} | [
"func",
"(",
"tb",
"*",
"LTable",
")",
"Append",
"(",
"value",
"LValue",
")",
"{",
"if",
"value",
"==",
"LNil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"tb",
".",
"array",
"==",
"nil",
"{",
"tb",
".",
"array",
"=",
"make",
"(",
"[",
"]",
"LValue",
",",
"0",
",",
"defaultArrayCap",
")",
"\n",
"}",
"\n",
"tb",
".",
"array",
"=",
"append",
"(",
"tb",
".",
"array",
",",
"value",
")",
"\n",
"}"
]
| // Append appends a given LValue to this LTable. | [
"Append",
"appends",
"a",
"given",
"LValue",
"to",
"this",
"LTable",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/table.go#L66-L74 |
146,918 | yuin/gopher-lua | table.go | Insert | func (tb *LTable) Insert(i int, value LValue) {
if tb.array == nil {
tb.array = make([]LValue, 0, defaultArrayCap)
}
if i > len(tb.array) {
tb.RawSetInt(i, value)
return
}
if i <= 0 {
tb.RawSet(LNumber(i), value)
return
}
i -= 1
tb.array = append(tb.array, LNil)
copy(tb.array[i+1:], tb.array[i:])
tb.array[i] = value
} | go | func (tb *LTable) Insert(i int, value LValue) {
if tb.array == nil {
tb.array = make([]LValue, 0, defaultArrayCap)
}
if i > len(tb.array) {
tb.RawSetInt(i, value)
return
}
if i <= 0 {
tb.RawSet(LNumber(i), value)
return
}
i -= 1
tb.array = append(tb.array, LNil)
copy(tb.array[i+1:], tb.array[i:])
tb.array[i] = value
} | [
"func",
"(",
"tb",
"*",
"LTable",
")",
"Insert",
"(",
"i",
"int",
",",
"value",
"LValue",
")",
"{",
"if",
"tb",
".",
"array",
"==",
"nil",
"{",
"tb",
".",
"array",
"=",
"make",
"(",
"[",
"]",
"LValue",
",",
"0",
",",
"defaultArrayCap",
")",
"\n",
"}",
"\n",
"if",
"i",
">",
"len",
"(",
"tb",
".",
"array",
")",
"{",
"tb",
".",
"RawSetInt",
"(",
"i",
",",
"value",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"i",
"<=",
"0",
"{",
"tb",
".",
"RawSet",
"(",
"LNumber",
"(",
"i",
")",
",",
"value",
")",
"\n",
"return",
"\n",
"}",
"\n",
"i",
"-=",
"1",
"\n",
"tb",
".",
"array",
"=",
"append",
"(",
"tb",
".",
"array",
",",
"LNil",
")",
"\n",
"copy",
"(",
"tb",
".",
"array",
"[",
"i",
"+",
"1",
":",
"]",
",",
"tb",
".",
"array",
"[",
"i",
":",
"]",
")",
"\n",
"tb",
".",
"array",
"[",
"i",
"]",
"=",
"value",
"\n",
"}"
]
| // Insert inserts a given LValue at position `i` in this table. | [
"Insert",
"inserts",
"a",
"given",
"LValue",
"at",
"position",
"i",
"in",
"this",
"table",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/table.go#L77-L93 |
146,919 | yuin/gopher-lua | table.go | MaxN | func (tb *LTable) MaxN() int {
if tb.array == nil {
return 0
}
for i := len(tb.array) - 1; i >= 0; i-- {
if tb.array[i] != LNil {
return i + 1
}
}
return 0
} | go | func (tb *LTable) MaxN() int {
if tb.array == nil {
return 0
}
for i := len(tb.array) - 1; i >= 0; i-- {
if tb.array[i] != LNil {
return i + 1
}
}
return 0
} | [
"func",
"(",
"tb",
"*",
"LTable",
")",
"MaxN",
"(",
")",
"int",
"{",
"if",
"tb",
".",
"array",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"for",
"i",
":=",
"len",
"(",
"tb",
".",
"array",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"if",
"tb",
".",
"array",
"[",
"i",
"]",
"!=",
"LNil",
"{",
"return",
"i",
"+",
"1",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
]
| // MaxN returns a maximum number key that nil value does not exist before it. | [
"MaxN",
"returns",
"a",
"maximum",
"number",
"key",
"that",
"nil",
"value",
"does",
"not",
"exist",
"before",
"it",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/table.go#L96-L106 |
146,920 | yuin/gopher-lua | table.go | Remove | func (tb *LTable) Remove(pos int) LValue {
if tb.array == nil {
return LNil
}
larray := len(tb.array)
if larray == 0 {
return LNil
}
i := pos - 1
oldval := LNil
switch {
case i >= larray:
// nothing to do
case i == larray-1 || i < 0:
oldval = tb.array[larray-1]
tb.array = tb.array[:larray-1]
default:
oldval = tb.array[i]
copy(tb.array[i:], tb.array[i+1:])
tb.array[larray-1] = nil
tb.array = tb.array[:larray-1]
}
return oldval
} | go | func (tb *LTable) Remove(pos int) LValue {
if tb.array == nil {
return LNil
}
larray := len(tb.array)
if larray == 0 {
return LNil
}
i := pos - 1
oldval := LNil
switch {
case i >= larray:
// nothing to do
case i == larray-1 || i < 0:
oldval = tb.array[larray-1]
tb.array = tb.array[:larray-1]
default:
oldval = tb.array[i]
copy(tb.array[i:], tb.array[i+1:])
tb.array[larray-1] = nil
tb.array = tb.array[:larray-1]
}
return oldval
} | [
"func",
"(",
"tb",
"*",
"LTable",
")",
"Remove",
"(",
"pos",
"int",
")",
"LValue",
"{",
"if",
"tb",
".",
"array",
"==",
"nil",
"{",
"return",
"LNil",
"\n",
"}",
"\n",
"larray",
":=",
"len",
"(",
"tb",
".",
"array",
")",
"\n",
"if",
"larray",
"==",
"0",
"{",
"return",
"LNil",
"\n",
"}",
"\n",
"i",
":=",
"pos",
"-",
"1",
"\n",
"oldval",
":=",
"LNil",
"\n",
"switch",
"{",
"case",
"i",
">=",
"larray",
":",
"// nothing to do",
"case",
"i",
"==",
"larray",
"-",
"1",
"||",
"i",
"<",
"0",
":",
"oldval",
"=",
"tb",
".",
"array",
"[",
"larray",
"-",
"1",
"]",
"\n",
"tb",
".",
"array",
"=",
"tb",
".",
"array",
"[",
":",
"larray",
"-",
"1",
"]",
"\n",
"default",
":",
"oldval",
"=",
"tb",
".",
"array",
"[",
"i",
"]",
"\n",
"copy",
"(",
"tb",
".",
"array",
"[",
"i",
":",
"]",
",",
"tb",
".",
"array",
"[",
"i",
"+",
"1",
":",
"]",
")",
"\n",
"tb",
".",
"array",
"[",
"larray",
"-",
"1",
"]",
"=",
"nil",
"\n",
"tb",
".",
"array",
"=",
"tb",
".",
"array",
"[",
":",
"larray",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"oldval",
"\n",
"}"
]
| // Remove removes from this table the element at a given position. | [
"Remove",
"removes",
"from",
"this",
"table",
"the",
"element",
"at",
"a",
"given",
"position",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/table.go#L109-L132 |
146,921 | yuin/gopher-lua | table.go | ForEach | func (tb *LTable) ForEach(cb func(LValue, LValue)) {
if tb.array != nil {
for i, v := range tb.array {
if v != LNil {
cb(LNumber(i+1), v)
}
}
}
if tb.strdict != nil {
for k, v := range tb.strdict {
if v != LNil {
cb(LString(k), v)
}
}
}
if tb.dict != nil {
for k, v := range tb.dict {
if v != LNil {
cb(k, v)
}
}
}
} | go | func (tb *LTable) ForEach(cb func(LValue, LValue)) {
if tb.array != nil {
for i, v := range tb.array {
if v != LNil {
cb(LNumber(i+1), v)
}
}
}
if tb.strdict != nil {
for k, v := range tb.strdict {
if v != LNil {
cb(LString(k), v)
}
}
}
if tb.dict != nil {
for k, v := range tb.dict {
if v != LNil {
cb(k, v)
}
}
}
} | [
"func",
"(",
"tb",
"*",
"LTable",
")",
"ForEach",
"(",
"cb",
"func",
"(",
"LValue",
",",
"LValue",
")",
")",
"{",
"if",
"tb",
".",
"array",
"!=",
"nil",
"{",
"for",
"i",
",",
"v",
":=",
"range",
"tb",
".",
"array",
"{",
"if",
"v",
"!=",
"LNil",
"{",
"cb",
"(",
"LNumber",
"(",
"i",
"+",
"1",
")",
",",
"v",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"tb",
".",
"strdict",
"!=",
"nil",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"tb",
".",
"strdict",
"{",
"if",
"v",
"!=",
"LNil",
"{",
"cb",
"(",
"LString",
"(",
"k",
")",
",",
"v",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"tb",
".",
"dict",
"!=",
"nil",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"tb",
".",
"dict",
"{",
"if",
"v",
"!=",
"LNil",
"{",
"cb",
"(",
"k",
",",
"v",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
| // ForEach iterates over this table of elements, yielding each in turn to a given function. | [
"ForEach",
"iterates",
"over",
"this",
"table",
"of",
"elements",
"yielding",
"each",
"in",
"turn",
"to",
"a",
"given",
"function",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/table.go#L316-L338 |
146,922 | yuin/gopher-lua | linit.go | OpenLibs | func (ls *LState) OpenLibs() {
// NB: Map iteration order in Go is deliberately randomised, so must open Load/Base
// prior to iterating.
for _, lib := range luaLibs {
ls.Push(ls.NewFunction(lib.libFunc))
ls.Push(LString(lib.libName))
ls.Call(1, 0)
}
} | go | func (ls *LState) OpenLibs() {
// NB: Map iteration order in Go is deliberately randomised, so must open Load/Base
// prior to iterating.
for _, lib := range luaLibs {
ls.Push(ls.NewFunction(lib.libFunc))
ls.Push(LString(lib.libName))
ls.Call(1, 0)
}
} | [
"func",
"(",
"ls",
"*",
"LState",
")",
"OpenLibs",
"(",
")",
"{",
"// NB: Map iteration order in Go is deliberately randomised, so must open Load/Base",
"// prior to iterating.",
"for",
"_",
",",
"lib",
":=",
"range",
"luaLibs",
"{",
"ls",
".",
"Push",
"(",
"ls",
".",
"NewFunction",
"(",
"lib",
".",
"libFunc",
")",
")",
"\n",
"ls",
".",
"Push",
"(",
"LString",
"(",
"lib",
".",
"libName",
")",
")",
"\n",
"ls",
".",
"Call",
"(",
"1",
",",
"0",
")",
"\n",
"}",
"\n",
"}"
]
| // OpenLibs loads the built-in libraries. It is equivalent to running OpenLoad,
// then OpenBase, then iterating over the other OpenXXX functions in any order. | [
"OpenLibs",
"loads",
"the",
"built",
"-",
"in",
"libraries",
".",
"It",
"is",
"equivalent",
"to",
"running",
"OpenLoad",
"then",
"OpenBase",
"then",
"iterating",
"over",
"the",
"other",
"OpenXXX",
"functions",
"in",
"any",
"order",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/linit.go#L46-L54 |
146,923 | yuin/gopher-lua | _state.go | NewThread | func (ls *LState) NewThread() (*LState, context.CancelFunc) {
thread := newLState(ls.Options)
thread.G = ls.G
thread.Env = ls.Env
var f context.CancelFunc = nil
if ls.ctx != nil {
thread.mainLoop = mainLoopWithContext
thread.ctx, f = context.WithCancel(ls.ctx)
}
return thread, f
} | go | func (ls *LState) NewThread() (*LState, context.CancelFunc) {
thread := newLState(ls.Options)
thread.G = ls.G
thread.Env = ls.Env
var f context.CancelFunc = nil
if ls.ctx != nil {
thread.mainLoop = mainLoopWithContext
thread.ctx, f = context.WithCancel(ls.ctx)
}
return thread, f
} | [
"func",
"(",
"ls",
"*",
"LState",
")",
"NewThread",
"(",
")",
"(",
"*",
"LState",
",",
"context",
".",
"CancelFunc",
")",
"{",
"thread",
":=",
"newLState",
"(",
"ls",
".",
"Options",
")",
"\n",
"thread",
".",
"G",
"=",
"ls",
".",
"G",
"\n",
"thread",
".",
"Env",
"=",
"ls",
".",
"Env",
"\n",
"var",
"f",
"context",
".",
"CancelFunc",
"=",
"nil",
"\n",
"if",
"ls",
".",
"ctx",
"!=",
"nil",
"{",
"thread",
".",
"mainLoop",
"=",
"mainLoopWithContext",
"\n",
"thread",
".",
"ctx",
",",
"f",
"=",
"context",
".",
"WithCancel",
"(",
"ls",
".",
"ctx",
")",
"\n",
"}",
"\n",
"return",
"thread",
",",
"f",
"\n",
"}"
]
| // NewThread returns a new LState that shares with the original state all global objects.
// If the original state has context.Context, the new state has a new child context of the original state and this function returns its cancel function. | [
"NewThread",
"returns",
"a",
"new",
"LState",
"that",
"shares",
"with",
"the",
"original",
"state",
"all",
"global",
"objects",
".",
"If",
"the",
"original",
"state",
"has",
"context",
".",
"Context",
"the",
"new",
"state",
"has",
"a",
"new",
"child",
"context",
"of",
"the",
"original",
"state",
"and",
"this",
"function",
"returns",
"its",
"cancel",
"function",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/_state.go#L1121-L1131 |
146,924 | yuin/gopher-lua | _state.go | SetContext | func (ls *LState) SetContext(ctx context.Context) {
ls.mainLoop = mainLoopWithContext
ls.ctx = ctx
} | go | func (ls *LState) SetContext(ctx context.Context) {
ls.mainLoop = mainLoopWithContext
ls.ctx = ctx
} | [
"func",
"(",
"ls",
"*",
"LState",
")",
"SetContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"ls",
".",
"mainLoop",
"=",
"mainLoopWithContext",
"\n",
"ls",
".",
"ctx",
"=",
"ctx",
"\n",
"}"
]
| // SetContext set a context ctx to this LState. The provided ctx must be non-nil. | [
"SetContext",
"set",
"a",
"context",
"ctx",
"to",
"this",
"LState",
".",
"The",
"provided",
"ctx",
"must",
"be",
"non",
"-",
"nil",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/_state.go#L1760-L1763 |
146,925 | yuin/gopher-lua | _state.go | RemoveContext | func (ls *LState) RemoveContext() context.Context {
oldctx := ls.ctx
ls.mainLoop = mainLoop
ls.ctx = nil
return oldctx
} | go | func (ls *LState) RemoveContext() context.Context {
oldctx := ls.ctx
ls.mainLoop = mainLoop
ls.ctx = nil
return oldctx
} | [
"func",
"(",
"ls",
"*",
"LState",
")",
"RemoveContext",
"(",
")",
"context",
".",
"Context",
"{",
"oldctx",
":=",
"ls",
".",
"ctx",
"\n",
"ls",
".",
"mainLoop",
"=",
"mainLoop",
"\n",
"ls",
".",
"ctx",
"=",
"nil",
"\n",
"return",
"oldctx",
"\n",
"}"
]
| // RemoveContext removes the context associated with this LState and returns this context. | [
"RemoveContext",
"removes",
"the",
"context",
"associated",
"with",
"this",
"LState",
"and",
"returns",
"this",
"context",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/_state.go#L1771-L1776 |
146,926 | yuin/gopher-lua | _state.go | ToChannel | func (ls *LState) ToChannel(n int) chan LValue {
if lv, ok := ls.Get(n).(LChannel); ok {
return (chan LValue)(lv)
}
return nil
} | go | func (ls *LState) ToChannel(n int) chan LValue {
if lv, ok := ls.Get(n).(LChannel); ok {
return (chan LValue)(lv)
}
return nil
} | [
"func",
"(",
"ls",
"*",
"LState",
")",
"ToChannel",
"(",
"n",
"int",
")",
"chan",
"LValue",
"{",
"if",
"lv",
",",
"ok",
":=",
"ls",
".",
"Get",
"(",
"n",
")",
".",
"(",
"LChannel",
")",
";",
"ok",
"{",
"return",
"(",
"chan",
"LValue",
")",
"(",
"lv",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
| // Converts the Lua value at the given acceptable index to the chan LValue. | [
"Converts",
"the",
"Lua",
"value",
"at",
"the",
"given",
"acceptable",
"index",
"to",
"the",
"chan",
"LValue",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/_state.go#L1779-L1784 |
146,927 | yuin/gopher-lua | value.go | LVAsString | func LVAsString(v LValue) string {
switch sn := v.(type) {
case LString, LNumber:
return sn.String()
default:
return ""
}
} | go | func LVAsString(v LValue) string {
switch sn := v.(type) {
case LString, LNumber:
return sn.String()
default:
return ""
}
} | [
"func",
"LVAsString",
"(",
"v",
"LValue",
")",
"string",
"{",
"switch",
"sn",
":=",
"v",
".",
"(",
"type",
")",
"{",
"case",
"LString",
",",
"LNumber",
":",
"return",
"sn",
".",
"String",
"(",
")",
"\n",
"default",
":",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"}"
]
| // LVAsString returns string representation of a given LValue
// if the LValue is a string or number, otherwise an empty string. | [
"LVAsString",
"returns",
"string",
"representation",
"of",
"a",
"given",
"LValue",
"if",
"the",
"LValue",
"is",
"a",
"string",
"or",
"number",
"otherwise",
"an",
"empty",
"string",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/value.go#L48-L55 |
146,928 | yuin/gopher-lua | value.go | LVAsNumber | func LVAsNumber(v LValue) LNumber {
switch lv := v.(type) {
case LNumber:
return lv
case LString:
if num, err := parseNumber(string(lv)); err == nil {
return num
}
}
return LNumber(0)
} | go | func LVAsNumber(v LValue) LNumber {
switch lv := v.(type) {
case LNumber:
return lv
case LString:
if num, err := parseNumber(string(lv)); err == nil {
return num
}
}
return LNumber(0)
} | [
"func",
"LVAsNumber",
"(",
"v",
"LValue",
")",
"LNumber",
"{",
"switch",
"lv",
":=",
"v",
".",
"(",
"type",
")",
"{",
"case",
"LNumber",
":",
"return",
"lv",
"\n",
"case",
"LString",
":",
"if",
"num",
",",
"err",
":=",
"parseNumber",
"(",
"string",
"(",
"lv",
")",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"num",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"LNumber",
"(",
"0",
")",
"\n",
"}"
]
| // LVAsNumber tries to convert a given LValue to a number. | [
"LVAsNumber",
"tries",
"to",
"convert",
"a",
"given",
"LValue",
"to",
"a",
"number",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/value.go#L69-L79 |
146,929 | yuin/gopher-lua | auxlib.go | PreloadModule | func (ls *LState) PreloadModule(name string, loader LGFunction) {
preload := ls.GetField(ls.GetField(ls.Get(EnvironIndex), "package"), "preload")
if _, ok := preload.(*LTable); !ok {
ls.RaiseError("package.preload must be a table")
}
ls.SetField(preload, name, ls.NewFunction(loader))
} | go | func (ls *LState) PreloadModule(name string, loader LGFunction) {
preload := ls.GetField(ls.GetField(ls.Get(EnvironIndex), "package"), "preload")
if _, ok := preload.(*LTable); !ok {
ls.RaiseError("package.preload must be a table")
}
ls.SetField(preload, name, ls.NewFunction(loader))
} | [
"func",
"(",
"ls",
"*",
"LState",
")",
"PreloadModule",
"(",
"name",
"string",
",",
"loader",
"LGFunction",
")",
"{",
"preload",
":=",
"ls",
".",
"GetField",
"(",
"ls",
".",
"GetField",
"(",
"ls",
".",
"Get",
"(",
"EnvironIndex",
")",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"preload",
".",
"(",
"*",
"LTable",
")",
";",
"!",
"ok",
"{",
"ls",
".",
"RaiseError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"ls",
".",
"SetField",
"(",
"preload",
",",
"name",
",",
"ls",
".",
"NewFunction",
"(",
"loader",
")",
")",
"\n",
"}"
]
| // Set a module loader to the package.preload table. | [
"Set",
"a",
"module",
"loader",
"to",
"the",
"package",
".",
"preload",
"table",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/auxlib.go#L425-L431 |
146,930 | yuin/gopher-lua | auxlib.go | CheckChannel | func (ls *LState) CheckChannel(n int) chan LValue {
v := ls.Get(n)
if ch, ok := v.(LChannel); ok {
return (chan LValue)(ch)
}
ls.TypeError(n, LTChannel)
return nil
} | go | func (ls *LState) CheckChannel(n int) chan LValue {
v := ls.Get(n)
if ch, ok := v.(LChannel); ok {
return (chan LValue)(ch)
}
ls.TypeError(n, LTChannel)
return nil
} | [
"func",
"(",
"ls",
"*",
"LState",
")",
"CheckChannel",
"(",
"n",
"int",
")",
"chan",
"LValue",
"{",
"v",
":=",
"ls",
".",
"Get",
"(",
"n",
")",
"\n",
"if",
"ch",
",",
"ok",
":=",
"v",
".",
"(",
"LChannel",
")",
";",
"ok",
"{",
"return",
"(",
"chan",
"LValue",
")",
"(",
"ch",
")",
"\n",
"}",
"\n",
"ls",
".",
"TypeError",
"(",
"n",
",",
"LTChannel",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // Checks whether the given index is an LChannel and returns this channel. | [
"Checks",
"whether",
"the",
"given",
"index",
"is",
"an",
"LChannel",
"and",
"returns",
"this",
"channel",
"."
]
| 8bfc7677f583b35a5663a9dd934c08f3b5774bbb | https://github.com/yuin/gopher-lua/blob/8bfc7677f583b35a5663a9dd934c08f3b5774bbb/auxlib.go#L434-L441 |
146,931 | bwmarrin/snowflake | snowflake.go | NewNode | func NewNode(node int64) (*Node, error) {
// re-calc in case custom NodeBits or StepBits were set
// DEPRECATED: the below block will be removed in a future release.
mu.Lock()
nodeMax = -1 ^ (-1 << NodeBits)
nodeMask = nodeMax << StepBits
stepMask = -1 ^ (-1 << StepBits)
timeShift = NodeBits + StepBits
nodeShift = StepBits
mu.Unlock()
n := Node{}
n.node = node
n.nodeMax = -1 ^ (-1 << NodeBits)
n.nodeMask = n.nodeMax << StepBits
n.stepMask = -1 ^ (-1 << StepBits)
n.timeShift = NodeBits + StepBits
n.nodeShift = StepBits
if n.node < 0 || n.node > n.nodeMax {
return nil, errors.New("Node number must be between 0 and " + strconv.FormatInt(n.nodeMax, 10))
}
var curTime = time.Now()
// add time.Duration to curTime to make sure we use the monotonic clock if available
n.epoch = curTime.Add(time.Unix(Epoch/1000, (Epoch%1000)*1000000).Sub(curTime))
return &n, nil
} | go | func NewNode(node int64) (*Node, error) {
// re-calc in case custom NodeBits or StepBits were set
// DEPRECATED: the below block will be removed in a future release.
mu.Lock()
nodeMax = -1 ^ (-1 << NodeBits)
nodeMask = nodeMax << StepBits
stepMask = -1 ^ (-1 << StepBits)
timeShift = NodeBits + StepBits
nodeShift = StepBits
mu.Unlock()
n := Node{}
n.node = node
n.nodeMax = -1 ^ (-1 << NodeBits)
n.nodeMask = n.nodeMax << StepBits
n.stepMask = -1 ^ (-1 << StepBits)
n.timeShift = NodeBits + StepBits
n.nodeShift = StepBits
if n.node < 0 || n.node > n.nodeMax {
return nil, errors.New("Node number must be between 0 and " + strconv.FormatInt(n.nodeMax, 10))
}
var curTime = time.Now()
// add time.Duration to curTime to make sure we use the monotonic clock if available
n.epoch = curTime.Add(time.Unix(Epoch/1000, (Epoch%1000)*1000000).Sub(curTime))
return &n, nil
} | [
"func",
"NewNode",
"(",
"node",
"int64",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"// re-calc in case custom NodeBits or StepBits were set",
"// DEPRECATED: the below block will be removed in a future release.",
"mu",
".",
"Lock",
"(",
")",
"\n",
"nodeMax",
"=",
"-",
"1",
"^",
"(",
"-",
"1",
"<<",
"NodeBits",
")",
"\n",
"nodeMask",
"=",
"nodeMax",
"<<",
"StepBits",
"\n",
"stepMask",
"=",
"-",
"1",
"^",
"(",
"-",
"1",
"<<",
"StepBits",
")",
"\n",
"timeShift",
"=",
"NodeBits",
"+",
"StepBits",
"\n",
"nodeShift",
"=",
"StepBits",
"\n",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"n",
":=",
"Node",
"{",
"}",
"\n",
"n",
".",
"node",
"=",
"node",
"\n",
"n",
".",
"nodeMax",
"=",
"-",
"1",
"^",
"(",
"-",
"1",
"<<",
"NodeBits",
")",
"\n",
"n",
".",
"nodeMask",
"=",
"n",
".",
"nodeMax",
"<<",
"StepBits",
"\n",
"n",
".",
"stepMask",
"=",
"-",
"1",
"^",
"(",
"-",
"1",
"<<",
"StepBits",
")",
"\n",
"n",
".",
"timeShift",
"=",
"NodeBits",
"+",
"StepBits",
"\n",
"n",
".",
"nodeShift",
"=",
"StepBits",
"\n\n",
"if",
"n",
".",
"node",
"<",
"0",
"||",
"n",
".",
"node",
">",
"n",
".",
"nodeMax",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
"+",
"strconv",
".",
"FormatInt",
"(",
"n",
".",
"nodeMax",
",",
"10",
")",
")",
"\n",
"}",
"\n\n",
"var",
"curTime",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"// add time.Duration to curTime to make sure we use the monotonic clock if available",
"n",
".",
"epoch",
"=",
"curTime",
".",
"Add",
"(",
"time",
".",
"Unix",
"(",
"Epoch",
"/",
"1000",
",",
"(",
"Epoch",
"%",
"1000",
")",
"*",
"1000000",
")",
".",
"Sub",
"(",
"curTime",
")",
")",
"\n\n",
"return",
"&",
"n",
",",
"nil",
"\n",
"}"
]
| // NewNode returns a new snowflake node that can be used to generate snowflake
// IDs | [
"NewNode",
"returns",
"a",
"new",
"snowflake",
"node",
"that",
"can",
"be",
"used",
"to",
"generate",
"snowflake",
"IDs"
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L100-L129 |
146,932 | bwmarrin/snowflake | snowflake.go | Generate | func (n *Node) Generate() ID {
n.mu.Lock()
now := time.Since(n.epoch).Nanoseconds() / 1000000
if now == n.time {
n.step = (n.step + 1) & n.stepMask
if n.step == 0 {
for now <= n.time {
now = time.Since(n.epoch).Nanoseconds() / 1000000
}
}
} else {
n.step = 0
}
n.time = now
r := ID((now)<<n.timeShift |
(n.node << n.nodeShift) |
(n.step),
)
n.mu.Unlock()
return r
} | go | func (n *Node) Generate() ID {
n.mu.Lock()
now := time.Since(n.epoch).Nanoseconds() / 1000000
if now == n.time {
n.step = (n.step + 1) & n.stepMask
if n.step == 0 {
for now <= n.time {
now = time.Since(n.epoch).Nanoseconds() / 1000000
}
}
} else {
n.step = 0
}
n.time = now
r := ID((now)<<n.timeShift |
(n.node << n.nodeShift) |
(n.step),
)
n.mu.Unlock()
return r
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Generate",
"(",
")",
"ID",
"{",
"n",
".",
"mu",
".",
"Lock",
"(",
")",
"\n\n",
"now",
":=",
"time",
".",
"Since",
"(",
"n",
".",
"epoch",
")",
".",
"Nanoseconds",
"(",
")",
"/",
"1000000",
"\n\n",
"if",
"now",
"==",
"n",
".",
"time",
"{",
"n",
".",
"step",
"=",
"(",
"n",
".",
"step",
"+",
"1",
")",
"&",
"n",
".",
"stepMask",
"\n\n",
"if",
"n",
".",
"step",
"==",
"0",
"{",
"for",
"now",
"<=",
"n",
".",
"time",
"{",
"now",
"=",
"time",
".",
"Since",
"(",
"n",
".",
"epoch",
")",
".",
"Nanoseconds",
"(",
")",
"/",
"1000000",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"n",
".",
"step",
"=",
"0",
"\n",
"}",
"\n\n",
"n",
".",
"time",
"=",
"now",
"\n\n",
"r",
":=",
"ID",
"(",
"(",
"now",
")",
"<<",
"n",
".",
"timeShift",
"|",
"(",
"n",
".",
"node",
"<<",
"n",
".",
"nodeShift",
")",
"|",
"(",
"n",
".",
"step",
")",
",",
")",
"\n\n",
"n",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"r",
"\n",
"}"
]
| // Generate creates and returns a unique snowflake ID
// To help guarantee uniqueness
// - Make sure your system is keeping accurate system time
// - Make sure you never have multiple nodes running with the same node ID | [
"Generate",
"creates",
"and",
"returns",
"a",
"unique",
"snowflake",
"ID",
"To",
"help",
"guarantee",
"uniqueness",
"-",
"Make",
"sure",
"your",
"system",
"is",
"keeping",
"accurate",
"system",
"time",
"-",
"Make",
"sure",
"you",
"never",
"have",
"multiple",
"nodes",
"running",
"with",
"the",
"same",
"node",
"ID"
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L135-L162 |
146,933 | bwmarrin/snowflake | snowflake.go | ParseString | func ParseString(id string) (ID, error) {
i, err := strconv.ParseInt(id, 10, 64)
return ID(i), err
} | go | func ParseString(id string) (ID, error) {
i, err := strconv.ParseInt(id, 10, 64)
return ID(i), err
} | [
"func",
"ParseString",
"(",
"id",
"string",
")",
"(",
"ID",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"id",
",",
"10",
",",
"64",
")",
"\n",
"return",
"ID",
"(",
"i",
")",
",",
"err",
"\n\n",
"}"
]
| // ParseString converts a string into a snowflake ID | [
"ParseString",
"converts",
"a",
"string",
"into",
"a",
"snowflake",
"ID"
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L180-L184 |
146,934 | bwmarrin/snowflake | snowflake.go | Base58 | func (f ID) Base58() string {
if f < 58 {
return string(encodeBase58Map[f])
}
b := make([]byte, 0, 11)
for f >= 58 {
b = append(b, encodeBase58Map[f%58])
f /= 58
}
b = append(b, encodeBase58Map[f])
for x, y := 0, len(b)-1; x < y; x, y = x+1, y-1 {
b[x], b[y] = b[y], b[x]
}
return string(b)
} | go | func (f ID) Base58() string {
if f < 58 {
return string(encodeBase58Map[f])
}
b := make([]byte, 0, 11)
for f >= 58 {
b = append(b, encodeBase58Map[f%58])
f /= 58
}
b = append(b, encodeBase58Map[f])
for x, y := 0, len(b)-1; x < y; x, y = x+1, y-1 {
b[x], b[y] = b[y], b[x]
}
return string(b)
} | [
"func",
"(",
"f",
"ID",
")",
"Base58",
"(",
")",
"string",
"{",
"if",
"f",
"<",
"58",
"{",
"return",
"string",
"(",
"encodeBase58Map",
"[",
"f",
"]",
")",
"\n",
"}",
"\n\n",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"11",
")",
"\n",
"for",
"f",
">=",
"58",
"{",
"b",
"=",
"append",
"(",
"b",
",",
"encodeBase58Map",
"[",
"f",
"%",
"58",
"]",
")",
"\n",
"f",
"/=",
"58",
"\n",
"}",
"\n",
"b",
"=",
"append",
"(",
"b",
",",
"encodeBase58Map",
"[",
"f",
"]",
")",
"\n\n",
"for",
"x",
",",
"y",
":=",
"0",
",",
"len",
"(",
"b",
")",
"-",
"1",
";",
"x",
"<",
"y",
";",
"x",
",",
"y",
"=",
"x",
"+",
"1",
",",
"y",
"-",
"1",
"{",
"b",
"[",
"x",
"]",
",",
"b",
"[",
"y",
"]",
"=",
"b",
"[",
"y",
"]",
",",
"b",
"[",
"x",
"]",
"\n",
"}",
"\n\n",
"return",
"string",
"(",
"b",
")",
"\n",
"}"
]
| // Base58 returns a base58 string of the snowflake ID | [
"Base58",
"returns",
"a",
"base58",
"string",
"of",
"the",
"snowflake",
"ID"
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L250-L268 |
146,935 | bwmarrin/snowflake | snowflake.go | ParseBase64 | func ParseBase64(id string) (ID, error) {
b, err := base64.StdEncoding.DecodeString(id)
if err != nil {
return -1, err
}
return ParseBytes(b)
} | go | func ParseBase64(id string) (ID, error) {
b, err := base64.StdEncoding.DecodeString(id)
if err != nil {
return -1, err
}
return ParseBytes(b)
} | [
"func",
"ParseBase64",
"(",
"id",
"string",
")",
"(",
"ID",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"base64",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"return",
"ParseBytes",
"(",
"b",
")",
"\n\n",
"}"
]
| // ParseBase64 converts a base64 string into a snowflake ID | [
"ParseBase64",
"converts",
"a",
"base64",
"string",
"into",
"a",
"snowflake",
"ID"
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L291-L298 |
146,936 | bwmarrin/snowflake | snowflake.go | ParseBytes | func ParseBytes(id []byte) (ID, error) {
i, err := strconv.ParseInt(string(id), 10, 64)
return ID(i), err
} | go | func ParseBytes(id []byte) (ID, error) {
i, err := strconv.ParseInt(string(id), 10, 64)
return ID(i), err
} | [
"func",
"ParseBytes",
"(",
"id",
"[",
"]",
"byte",
")",
"(",
"ID",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"string",
"(",
"id",
")",
",",
"10",
",",
"64",
")",
"\n",
"return",
"ID",
"(",
"i",
")",
",",
"err",
"\n",
"}"
]
| // ParseBytes converts a byte slice into a snowflake ID | [
"ParseBytes",
"converts",
"a",
"byte",
"slice",
"into",
"a",
"snowflake",
"ID"
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L306-L309 |
146,937 | bwmarrin/snowflake | snowflake.go | IntBytes | func (f ID) IntBytes() [8]byte {
var b [8]byte
binary.BigEndian.PutUint64(b[:], uint64(f))
return b
} | go | func (f ID) IntBytes() [8]byte {
var b [8]byte
binary.BigEndian.PutUint64(b[:], uint64(f))
return b
} | [
"func",
"(",
"f",
"ID",
")",
"IntBytes",
"(",
")",
"[",
"8",
"]",
"byte",
"{",
"var",
"b",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint64",
"(",
"b",
"[",
":",
"]",
",",
"uint64",
"(",
"f",
")",
")",
"\n",
"return",
"b",
"\n",
"}"
]
| // IntBytes returns an array of bytes of the snowflake ID, encoded as a
// big endian integer. | [
"IntBytes",
"returns",
"an",
"array",
"of",
"bytes",
"of",
"the",
"snowflake",
"ID",
"encoded",
"as",
"a",
"big",
"endian",
"integer",
"."
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L313-L317 |
146,938 | bwmarrin/snowflake | snowflake.go | ParseIntBytes | func ParseIntBytes(id [8]byte) ID {
return ID(int64(binary.BigEndian.Uint64(id[:])))
} | go | func ParseIntBytes(id [8]byte) ID {
return ID(int64(binary.BigEndian.Uint64(id[:])))
} | [
"func",
"ParseIntBytes",
"(",
"id",
"[",
"8",
"]",
"byte",
")",
"ID",
"{",
"return",
"ID",
"(",
"int64",
"(",
"binary",
".",
"BigEndian",
".",
"Uint64",
"(",
"id",
"[",
":",
"]",
")",
")",
")",
"\n",
"}"
]
| // ParseIntBytes converts an array of bytes encoded as big endian integer as
// a snowflake ID | [
"ParseIntBytes",
"converts",
"an",
"array",
"of",
"bytes",
"encoded",
"as",
"big",
"endian",
"integer",
"as",
"a",
"snowflake",
"ID"
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L321-L323 |
146,939 | bwmarrin/snowflake | snowflake.go | MarshalJSON | func (f ID) MarshalJSON() ([]byte, error) {
buff := make([]byte, 0, 22)
buff = append(buff, '"')
buff = strconv.AppendInt(buff, int64(f), 10)
buff = append(buff, '"')
return buff, nil
} | go | func (f ID) MarshalJSON() ([]byte, error) {
buff := make([]byte, 0, 22)
buff = append(buff, '"')
buff = strconv.AppendInt(buff, int64(f), 10)
buff = append(buff, '"')
return buff, nil
} | [
"func",
"(",
"f",
"ID",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buff",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"22",
")",
"\n",
"buff",
"=",
"append",
"(",
"buff",
",",
"'\"'",
")",
"\n",
"buff",
"=",
"strconv",
".",
"AppendInt",
"(",
"buff",
",",
"int64",
"(",
"f",
")",
",",
"10",
")",
"\n",
"buff",
"=",
"append",
"(",
"buff",
",",
"'\"'",
")",
"\n",
"return",
"buff",
",",
"nil",
"\n",
"}"
]
| // MarshalJSON returns a json byte array string of the snowflake ID. | [
"MarshalJSON",
"returns",
"a",
"json",
"byte",
"array",
"string",
"of",
"the",
"snowflake",
"ID",
"."
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L344-L350 |
146,940 | bwmarrin/snowflake | snowflake.go | UnmarshalJSON | func (f *ID) UnmarshalJSON(b []byte) error {
if len(b) < 3 || b[0] != '"' || b[len(b)-1] != '"' {
return JSONSyntaxError{b}
}
i, err := strconv.ParseInt(string(b[1:len(b)-1]), 10, 64)
if err != nil {
return err
}
*f = ID(i)
return nil
} | go | func (f *ID) UnmarshalJSON(b []byte) error {
if len(b) < 3 || b[0] != '"' || b[len(b)-1] != '"' {
return JSONSyntaxError{b}
}
i, err := strconv.ParseInt(string(b[1:len(b)-1]), 10, 64)
if err != nil {
return err
}
*f = ID(i)
return nil
} | [
"func",
"(",
"f",
"*",
"ID",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"b",
")",
"<",
"3",
"||",
"b",
"[",
"0",
"]",
"!=",
"'\"'",
"||",
"b",
"[",
"len",
"(",
"b",
")",
"-",
"1",
"]",
"!=",
"'\"'",
"{",
"return",
"JSONSyntaxError",
"{",
"b",
"}",
"\n",
"}",
"\n\n",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"string",
"(",
"b",
"[",
"1",
":",
"len",
"(",
"b",
")",
"-",
"1",
"]",
")",
",",
"10",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"f",
"=",
"ID",
"(",
"i",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // UnmarshalJSON converts a json byte array of a snowflake ID into an ID type. | [
"UnmarshalJSON",
"converts",
"a",
"json",
"byte",
"array",
"of",
"a",
"snowflake",
"ID",
"into",
"an",
"ID",
"type",
"."
]
| c09e69ae59935edf6d85799e858c26de86b04cb3 | https://github.com/bwmarrin/snowflake/blob/c09e69ae59935edf6d85799e858c26de86b04cb3/snowflake.go#L353-L365 |
146,941 | grafov/m3u8 | writer.go | Append | func (p *MasterPlaylist) Append(uri string, chunklist *MediaPlaylist, params VariantParams) {
v := new(Variant)
v.URI = uri
v.Chunklist = chunklist
v.VariantParams = params
p.Variants = append(p.Variants, v)
if len(v.Alternatives) > 0 {
// From section 7:
// The EXT-X-MEDIA tag and the AUDIO, VIDEO and SUBTITLES attributes of
// the EXT-X-STREAM-INF tag are backward compatible to protocol version
// 1, but playback on older clients may not be desirable. A server MAY
// consider indicating a EXT-X-VERSION of 4 or higher in the Master
// Playlist but is not required to do so.
version(&p.ver, 4) // so it is optional and in theory may be set to ver.1
// but more tests required
}
p.buf.Reset()
} | go | func (p *MasterPlaylist) Append(uri string, chunklist *MediaPlaylist, params VariantParams) {
v := new(Variant)
v.URI = uri
v.Chunklist = chunklist
v.VariantParams = params
p.Variants = append(p.Variants, v)
if len(v.Alternatives) > 0 {
// From section 7:
// The EXT-X-MEDIA tag and the AUDIO, VIDEO and SUBTITLES attributes of
// the EXT-X-STREAM-INF tag are backward compatible to protocol version
// 1, but playback on older clients may not be desirable. A server MAY
// consider indicating a EXT-X-VERSION of 4 or higher in the Master
// Playlist but is not required to do so.
version(&p.ver, 4) // so it is optional and in theory may be set to ver.1
// but more tests required
}
p.buf.Reset()
} | [
"func",
"(",
"p",
"*",
"MasterPlaylist",
")",
"Append",
"(",
"uri",
"string",
",",
"chunklist",
"*",
"MediaPlaylist",
",",
"params",
"VariantParams",
")",
"{",
"v",
":=",
"new",
"(",
"Variant",
")",
"\n",
"v",
".",
"URI",
"=",
"uri",
"\n",
"v",
".",
"Chunklist",
"=",
"chunklist",
"\n",
"v",
".",
"VariantParams",
"=",
"params",
"\n",
"p",
".",
"Variants",
"=",
"append",
"(",
"p",
".",
"Variants",
",",
"v",
")",
"\n",
"if",
"len",
"(",
"v",
".",
"Alternatives",
")",
">",
"0",
"{",
"// From section 7:",
"// The EXT-X-MEDIA tag and the AUDIO, VIDEO and SUBTITLES attributes of",
"// the EXT-X-STREAM-INF tag are backward compatible to protocol version",
"// 1, but playback on older clients may not be desirable. A server MAY",
"// consider indicating a EXT-X-VERSION of 4 or higher in the Master",
"// Playlist but is not required to do so.",
"version",
"(",
"&",
"p",
".",
"ver",
",",
"4",
")",
"// so it is optional and in theory may be set to ver.1",
"\n",
"// but more tests required",
"}",
"\n",
"p",
".",
"buf",
".",
"Reset",
"(",
")",
"\n",
"}"
]
| // Append variant to master playlist.
// This operation does reset playlist cache. | [
"Append",
"variant",
"to",
"master",
"playlist",
".",
"This",
"operation",
"does",
"reset",
"playlist",
"cache",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L49-L66 |
146,942 | grafov/m3u8 | writer.go | Encode | func (p *MasterPlaylist) Encode() *bytes.Buffer {
if p.buf.Len() > 0 {
return &p.buf
}
p.buf.WriteString("#EXTM3U\n#EXT-X-VERSION:")
p.buf.WriteString(strver(p.ver))
p.buf.WriteRune('\n')
if p.IndependentSegments() {
p.buf.WriteString("#EXT-X-INDEPENDENT-SEGMENTS\n")
}
var altsWritten map[string]bool = make(map[string]bool)
for _, pl := range p.Variants {
if pl.Alternatives != nil {
for _, alt := range pl.Alternatives {
// Make sure that we only write out an alternative once
altKey := fmt.Sprintf("%s-%s-%s-%s", alt.Type, alt.GroupId, alt.Name, alt.Language)
if altsWritten[altKey] {
continue
}
altsWritten[altKey] = true
p.buf.WriteString("#EXT-X-MEDIA:")
if alt.Type != "" {
p.buf.WriteString("TYPE=") // Type should not be quoted
p.buf.WriteString(alt.Type)
}
if alt.GroupId != "" {
p.buf.WriteString(",GROUP-ID=\"")
p.buf.WriteString(alt.GroupId)
p.buf.WriteRune('"')
}
if alt.Name != "" {
p.buf.WriteString(",NAME=\"")
p.buf.WriteString(alt.Name)
p.buf.WriteRune('"')
}
p.buf.WriteString(",DEFAULT=")
if alt.Default {
p.buf.WriteString("YES")
} else {
p.buf.WriteString("NO")
}
if alt.Autoselect != "" {
p.buf.WriteString(",AUTOSELECT=")
p.buf.WriteString(alt.Autoselect)
}
if alt.Language != "" {
p.buf.WriteString(",LANGUAGE=\"")
p.buf.WriteString(alt.Language)
p.buf.WriteRune('"')
}
if alt.Forced != "" {
p.buf.WriteString(",FORCED=\"")
p.buf.WriteString(alt.Forced)
p.buf.WriteRune('"')
}
if alt.Characteristics != "" {
p.buf.WriteString(",CHARACTERISTICS=\"")
p.buf.WriteString(alt.Characteristics)
p.buf.WriteRune('"')
}
if alt.Subtitles != "" {
p.buf.WriteString(",SUBTITLES=\"")
p.buf.WriteString(alt.Subtitles)
p.buf.WriteRune('"')
}
if alt.URI != "" {
p.buf.WriteString(",URI=\"")
p.buf.WriteString(alt.URI)
p.buf.WriteRune('"')
}
p.buf.WriteRune('\n')
}
}
if pl.Iframe {
p.buf.WriteString("#EXT-X-I-FRAME-STREAM-INF:PROGRAM-ID=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.ProgramId), 10))
p.buf.WriteString(",BANDWIDTH=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10))
if pl.Codecs != "" {
p.buf.WriteString(",CODECS=\"")
p.buf.WriteString(pl.Codecs)
p.buf.WriteRune('"')
}
if pl.Resolution != "" {
p.buf.WriteString(",RESOLUTION=") // Resolution should not be quoted
p.buf.WriteString(pl.Resolution)
}
if pl.Video != "" {
p.buf.WriteString(",VIDEO=\"")
p.buf.WriteString(pl.Video)
p.buf.WriteRune('"')
}
if pl.URI != "" {
p.buf.WriteString(",URI=\"")
p.buf.WriteString(pl.URI)
p.buf.WriteRune('"')
}
p.buf.WriteRune('\n')
} else {
p.buf.WriteString("#EXT-X-STREAM-INF:PROGRAM-ID=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.ProgramId), 10))
p.buf.WriteString(",BANDWIDTH=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10))
if pl.AverageBandwidth != 0 {
p.buf.WriteString(",AVERAGE-BANDWIDTH=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10))
}
if pl.Codecs != "" {
p.buf.WriteString(",CODECS=\"")
p.buf.WriteString(pl.Codecs)
p.buf.WriteRune('"')
}
if pl.Resolution != "" {
p.buf.WriteString(",RESOLUTION=") // Resolution should not be quoted
p.buf.WriteString(pl.Resolution)
}
if pl.Audio != "" {
p.buf.WriteString(",AUDIO=\"")
p.buf.WriteString(pl.Audio)
p.buf.WriteRune('"')
}
if pl.Video != "" {
p.buf.WriteString(",VIDEO=\"")
p.buf.WriteString(pl.Video)
p.buf.WriteRune('"')
}
if pl.Captions != "" {
p.buf.WriteString(",CLOSED-CAPTIONS=")
if pl.Captions == "NONE" {
p.buf.WriteString(pl.Captions) // CC should not be quoted when eq NONE
} else {
p.buf.WriteRune('"')
p.buf.WriteString(pl.Captions)
p.buf.WriteRune('"')
}
}
if pl.Subtitles != "" {
p.buf.WriteString(",SUBTITLES=\"")
p.buf.WriteString(pl.Subtitles)
p.buf.WriteRune('"')
}
if pl.Name != "" {
p.buf.WriteString(",NAME=\"")
p.buf.WriteString(pl.Name)
p.buf.WriteRune('"')
}
if pl.FrameRate != 0 {
p.buf.WriteString(",FRAME-RATE=")
p.buf.WriteString(strconv.FormatFloat(pl.FrameRate, 'f', 3, 64))
}
p.buf.WriteRune('\n')
p.buf.WriteString(pl.URI)
if p.Args != "" {
if strings.Contains(pl.URI, "?") {
p.buf.WriteRune('&')
} else {
p.buf.WriteRune('?')
}
p.buf.WriteString(p.Args)
}
p.buf.WriteRune('\n')
}
}
return &p.buf
} | go | func (p *MasterPlaylist) Encode() *bytes.Buffer {
if p.buf.Len() > 0 {
return &p.buf
}
p.buf.WriteString("#EXTM3U\n#EXT-X-VERSION:")
p.buf.WriteString(strver(p.ver))
p.buf.WriteRune('\n')
if p.IndependentSegments() {
p.buf.WriteString("#EXT-X-INDEPENDENT-SEGMENTS\n")
}
var altsWritten map[string]bool = make(map[string]bool)
for _, pl := range p.Variants {
if pl.Alternatives != nil {
for _, alt := range pl.Alternatives {
// Make sure that we only write out an alternative once
altKey := fmt.Sprintf("%s-%s-%s-%s", alt.Type, alt.GroupId, alt.Name, alt.Language)
if altsWritten[altKey] {
continue
}
altsWritten[altKey] = true
p.buf.WriteString("#EXT-X-MEDIA:")
if alt.Type != "" {
p.buf.WriteString("TYPE=") // Type should not be quoted
p.buf.WriteString(alt.Type)
}
if alt.GroupId != "" {
p.buf.WriteString(",GROUP-ID=\"")
p.buf.WriteString(alt.GroupId)
p.buf.WriteRune('"')
}
if alt.Name != "" {
p.buf.WriteString(",NAME=\"")
p.buf.WriteString(alt.Name)
p.buf.WriteRune('"')
}
p.buf.WriteString(",DEFAULT=")
if alt.Default {
p.buf.WriteString("YES")
} else {
p.buf.WriteString("NO")
}
if alt.Autoselect != "" {
p.buf.WriteString(",AUTOSELECT=")
p.buf.WriteString(alt.Autoselect)
}
if alt.Language != "" {
p.buf.WriteString(",LANGUAGE=\"")
p.buf.WriteString(alt.Language)
p.buf.WriteRune('"')
}
if alt.Forced != "" {
p.buf.WriteString(",FORCED=\"")
p.buf.WriteString(alt.Forced)
p.buf.WriteRune('"')
}
if alt.Characteristics != "" {
p.buf.WriteString(",CHARACTERISTICS=\"")
p.buf.WriteString(alt.Characteristics)
p.buf.WriteRune('"')
}
if alt.Subtitles != "" {
p.buf.WriteString(",SUBTITLES=\"")
p.buf.WriteString(alt.Subtitles)
p.buf.WriteRune('"')
}
if alt.URI != "" {
p.buf.WriteString(",URI=\"")
p.buf.WriteString(alt.URI)
p.buf.WriteRune('"')
}
p.buf.WriteRune('\n')
}
}
if pl.Iframe {
p.buf.WriteString("#EXT-X-I-FRAME-STREAM-INF:PROGRAM-ID=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.ProgramId), 10))
p.buf.WriteString(",BANDWIDTH=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10))
if pl.Codecs != "" {
p.buf.WriteString(",CODECS=\"")
p.buf.WriteString(pl.Codecs)
p.buf.WriteRune('"')
}
if pl.Resolution != "" {
p.buf.WriteString(",RESOLUTION=") // Resolution should not be quoted
p.buf.WriteString(pl.Resolution)
}
if pl.Video != "" {
p.buf.WriteString(",VIDEO=\"")
p.buf.WriteString(pl.Video)
p.buf.WriteRune('"')
}
if pl.URI != "" {
p.buf.WriteString(",URI=\"")
p.buf.WriteString(pl.URI)
p.buf.WriteRune('"')
}
p.buf.WriteRune('\n')
} else {
p.buf.WriteString("#EXT-X-STREAM-INF:PROGRAM-ID=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.ProgramId), 10))
p.buf.WriteString(",BANDWIDTH=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10))
if pl.AverageBandwidth != 0 {
p.buf.WriteString(",AVERAGE-BANDWIDTH=")
p.buf.WriteString(strconv.FormatUint(uint64(pl.Bandwidth), 10))
}
if pl.Codecs != "" {
p.buf.WriteString(",CODECS=\"")
p.buf.WriteString(pl.Codecs)
p.buf.WriteRune('"')
}
if pl.Resolution != "" {
p.buf.WriteString(",RESOLUTION=") // Resolution should not be quoted
p.buf.WriteString(pl.Resolution)
}
if pl.Audio != "" {
p.buf.WriteString(",AUDIO=\"")
p.buf.WriteString(pl.Audio)
p.buf.WriteRune('"')
}
if pl.Video != "" {
p.buf.WriteString(",VIDEO=\"")
p.buf.WriteString(pl.Video)
p.buf.WriteRune('"')
}
if pl.Captions != "" {
p.buf.WriteString(",CLOSED-CAPTIONS=")
if pl.Captions == "NONE" {
p.buf.WriteString(pl.Captions) // CC should not be quoted when eq NONE
} else {
p.buf.WriteRune('"')
p.buf.WriteString(pl.Captions)
p.buf.WriteRune('"')
}
}
if pl.Subtitles != "" {
p.buf.WriteString(",SUBTITLES=\"")
p.buf.WriteString(pl.Subtitles)
p.buf.WriteRune('"')
}
if pl.Name != "" {
p.buf.WriteString(",NAME=\"")
p.buf.WriteString(pl.Name)
p.buf.WriteRune('"')
}
if pl.FrameRate != 0 {
p.buf.WriteString(",FRAME-RATE=")
p.buf.WriteString(strconv.FormatFloat(pl.FrameRate, 'f', 3, 64))
}
p.buf.WriteRune('\n')
p.buf.WriteString(pl.URI)
if p.Args != "" {
if strings.Contains(pl.URI, "?") {
p.buf.WriteRune('&')
} else {
p.buf.WriteRune('?')
}
p.buf.WriteString(p.Args)
}
p.buf.WriteRune('\n')
}
}
return &p.buf
} | [
"func",
"(",
"p",
"*",
"MasterPlaylist",
")",
"Encode",
"(",
")",
"*",
"bytes",
".",
"Buffer",
"{",
"if",
"p",
".",
"buf",
".",
"Len",
"(",
")",
">",
"0",
"{",
"return",
"&",
"p",
".",
"buf",
"\n",
"}",
"\n\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"strver",
"(",
"p",
".",
"ver",
")",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\\n'",
")",
"\n\n",
"if",
"p",
".",
"IndependentSegments",
"(",
")",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"altsWritten",
"map",
"[",
"string",
"]",
"bool",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n\n",
"for",
"_",
",",
"pl",
":=",
"range",
"p",
".",
"Variants",
"{",
"if",
"pl",
".",
"Alternatives",
"!=",
"nil",
"{",
"for",
"_",
",",
"alt",
":=",
"range",
"pl",
".",
"Alternatives",
"{",
"// Make sure that we only write out an alternative once",
"altKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"alt",
".",
"Type",
",",
"alt",
".",
"GroupId",
",",
"alt",
".",
"Name",
",",
"alt",
".",
"Language",
")",
"\n",
"if",
"altsWritten",
"[",
"altKey",
"]",
"{",
"continue",
"\n",
"}",
"\n",
"altsWritten",
"[",
"altKey",
"]",
"=",
"true",
"\n\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"if",
"alt",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"// Type should not be quoted",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"Type",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"GroupId",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"GroupId",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"Name",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"Name",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"if",
"alt",
".",
"Default",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"Autoselect",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"Autoselect",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"Language",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"Language",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"Forced",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"Forced",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"Characteristics",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"Characteristics",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"Subtitles",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"Subtitles",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"alt",
".",
"URI",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"alt",
".",
"URI",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\\n'",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Iframe",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"pl",
".",
"ProgramId",
")",
",",
"10",
")",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"pl",
".",
"Bandwidth",
")",
",",
"10",
")",
")",
"\n",
"if",
"pl",
".",
"Codecs",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Codecs",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Resolution",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"// Resolution should not be quoted",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Resolution",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Video",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Video",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"URI",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"URI",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\\n'",
")",
"\n",
"}",
"else",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"pl",
".",
"ProgramId",
")",
",",
"10",
")",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"pl",
".",
"Bandwidth",
")",
",",
"10",
")",
")",
"\n",
"if",
"pl",
".",
"AverageBandwidth",
"!=",
"0",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"strconv",
".",
"FormatUint",
"(",
"uint64",
"(",
"pl",
".",
"Bandwidth",
")",
",",
"10",
")",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Codecs",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Codecs",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Resolution",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"// Resolution should not be quoted",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Resolution",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Audio",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Audio",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Video",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Video",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Captions",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"if",
"pl",
".",
"Captions",
"==",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Captions",
")",
"// CC should not be quoted when eq NONE",
"\n",
"}",
"else",
"{",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Captions",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Subtitles",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Subtitles",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"Name",
"!=",
"\"",
"\"",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"Name",
")",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
"\n",
"}",
"\n",
"if",
"pl",
".",
"FrameRate",
"!=",
"0",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"strconv",
".",
"FormatFloat",
"(",
"pl",
".",
"FrameRate",
",",
"'f'",
",",
"3",
",",
"64",
")",
")",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\\n'",
")",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"pl",
".",
"URI",
")",
"\n",
"if",
"p",
".",
"Args",
"!=",
"\"",
"\"",
"{",
"if",
"strings",
".",
"Contains",
"(",
"pl",
".",
"URI",
",",
"\"",
"\"",
")",
"{",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'&'",
")",
"\n",
"}",
"else",
"{",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'?'",
")",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"WriteString",
"(",
"p",
".",
"Args",
")",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"WriteRune",
"(",
"'\\n'",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"p",
".",
"buf",
"\n",
"}"
]
| // Generate output in M3U8 format. | [
"Generate",
"output",
"in",
"M3U8",
"format",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L73-L243 |
146,943 | grafov/m3u8 | writer.go | NewMediaPlaylist | func NewMediaPlaylist(winsize uint, capacity uint) (*MediaPlaylist, error) {
p := new(MediaPlaylist)
p.ver = minver
p.capacity = capacity
if err := p.SetWinSize(winsize); err != nil {
return nil, err
}
p.Segments = make([]*MediaSegment, capacity)
return p, nil
} | go | func NewMediaPlaylist(winsize uint, capacity uint) (*MediaPlaylist, error) {
p := new(MediaPlaylist)
p.ver = minver
p.capacity = capacity
if err := p.SetWinSize(winsize); err != nil {
return nil, err
}
p.Segments = make([]*MediaSegment, capacity)
return p, nil
} | [
"func",
"NewMediaPlaylist",
"(",
"winsize",
"uint",
",",
"capacity",
"uint",
")",
"(",
"*",
"MediaPlaylist",
",",
"error",
")",
"{",
"p",
":=",
"new",
"(",
"MediaPlaylist",
")",
"\n",
"p",
".",
"ver",
"=",
"minver",
"\n",
"p",
".",
"capacity",
"=",
"capacity",
"\n",
"if",
"err",
":=",
"p",
".",
"SetWinSize",
"(",
"winsize",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"p",
".",
"Segments",
"=",
"make",
"(",
"[",
"]",
"*",
"MediaSegment",
",",
"capacity",
")",
"\n",
"return",
"p",
",",
"nil",
"\n",
"}"
]
| // Creates new media playlist structure.
// Winsize defines how much items will displayed on playlist generation.
// Capacity is total size of a playlist. | [
"Creates",
"new",
"media",
"playlist",
"structure",
".",
"Winsize",
"defines",
"how",
"much",
"items",
"will",
"displayed",
"on",
"playlist",
"generation",
".",
"Capacity",
"is",
"total",
"size",
"of",
"a",
"playlist",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L278-L287 |
146,944 | grafov/m3u8 | writer.go | last | func (p *MediaPlaylist) last() uint {
if p.tail == 0 {
return p.capacity - 1
}
return p.tail - 1
} | go | func (p *MediaPlaylist) last() uint {
if p.tail == 0 {
return p.capacity - 1
}
return p.tail - 1
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"last",
"(",
")",
"uint",
"{",
"if",
"p",
".",
"tail",
"==",
"0",
"{",
"return",
"p",
".",
"capacity",
"-",
"1",
"\n",
"}",
"\n",
"return",
"p",
".",
"tail",
"-",
"1",
"\n",
"}"
]
| // last returns the previously written segment's index | [
"last",
"returns",
"the",
"previously",
"written",
"segment",
"s",
"index"
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L290-L295 |
146,945 | grafov/m3u8 | writer.go | Remove | func (p *MediaPlaylist) Remove() (err error) {
if p.count == 0 {
return errors.New("playlist is empty")
}
p.head = (p.head + 1) % p.capacity
p.count--
if !p.Closed {
p.SeqNo++
}
p.buf.Reset()
return nil
} | go | func (p *MediaPlaylist) Remove() (err error) {
if p.count == 0 {
return errors.New("playlist is empty")
}
p.head = (p.head + 1) % p.capacity
p.count--
if !p.Closed {
p.SeqNo++
}
p.buf.Reset()
return nil
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"Remove",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"p",
".",
"count",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"p",
".",
"head",
"=",
"(",
"p",
".",
"head",
"+",
"1",
")",
"%",
"p",
".",
"capacity",
"\n",
"p",
".",
"count",
"--",
"\n",
"if",
"!",
"p",
".",
"Closed",
"{",
"p",
".",
"SeqNo",
"++",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"Reset",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // Remove current segment from the head of chunk slice form a media playlist. Useful for sliding playlists.
// This operation does reset playlist cache. | [
"Remove",
"current",
"segment",
"from",
"the",
"head",
"of",
"chunk",
"slice",
"form",
"a",
"media",
"playlist",
".",
"Useful",
"for",
"sliding",
"playlists",
".",
"This",
"operation",
"does",
"reset",
"playlist",
"cache",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L299-L310 |
146,946 | grafov/m3u8 | writer.go | Append | func (p *MediaPlaylist) Append(uri string, duration float64, title string) error {
seg := new(MediaSegment)
seg.URI = uri
seg.Duration = duration
seg.Title = title
return p.AppendSegment(seg)
} | go | func (p *MediaPlaylist) Append(uri string, duration float64, title string) error {
seg := new(MediaSegment)
seg.URI = uri
seg.Duration = duration
seg.Title = title
return p.AppendSegment(seg)
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"Append",
"(",
"uri",
"string",
",",
"duration",
"float64",
",",
"title",
"string",
")",
"error",
"{",
"seg",
":=",
"new",
"(",
"MediaSegment",
")",
"\n",
"seg",
".",
"URI",
"=",
"uri",
"\n",
"seg",
".",
"Duration",
"=",
"duration",
"\n",
"seg",
".",
"Title",
"=",
"title",
"\n",
"return",
"p",
".",
"AppendSegment",
"(",
"seg",
")",
"\n",
"}"
]
| // Append general chunk to the tail of chunk slice for a media playlist.
// This operation does reset playlist cache. | [
"Append",
"general",
"chunk",
"to",
"the",
"tail",
"of",
"chunk",
"slice",
"for",
"a",
"media",
"playlist",
".",
"This",
"operation",
"does",
"reset",
"playlist",
"cache",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L314-L320 |
146,947 | grafov/m3u8 | writer.go | AppendSegment | func (p *MediaPlaylist) AppendSegment(seg *MediaSegment) error {
if p.head == p.tail && p.count > 0 {
return ErrPlaylistFull
}
seg.SeqId = p.SeqNo
if p.count > 0 {
seg.SeqId = p.Segments[(p.capacity+p.tail-1)%p.capacity].SeqId + 1
}
p.Segments[p.tail] = seg
p.tail = (p.tail + 1) % p.capacity
p.count++
if p.TargetDuration < seg.Duration {
p.TargetDuration = math.Ceil(seg.Duration)
}
p.buf.Reset()
return nil
} | go | func (p *MediaPlaylist) AppendSegment(seg *MediaSegment) error {
if p.head == p.tail && p.count > 0 {
return ErrPlaylistFull
}
seg.SeqId = p.SeqNo
if p.count > 0 {
seg.SeqId = p.Segments[(p.capacity+p.tail-1)%p.capacity].SeqId + 1
}
p.Segments[p.tail] = seg
p.tail = (p.tail + 1) % p.capacity
p.count++
if p.TargetDuration < seg.Duration {
p.TargetDuration = math.Ceil(seg.Duration)
}
p.buf.Reset()
return nil
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"AppendSegment",
"(",
"seg",
"*",
"MediaSegment",
")",
"error",
"{",
"if",
"p",
".",
"head",
"==",
"p",
".",
"tail",
"&&",
"p",
".",
"count",
">",
"0",
"{",
"return",
"ErrPlaylistFull",
"\n",
"}",
"\n",
"seg",
".",
"SeqId",
"=",
"p",
".",
"SeqNo",
"\n",
"if",
"p",
".",
"count",
">",
"0",
"{",
"seg",
".",
"SeqId",
"=",
"p",
".",
"Segments",
"[",
"(",
"p",
".",
"capacity",
"+",
"p",
".",
"tail",
"-",
"1",
")",
"%",
"p",
".",
"capacity",
"]",
".",
"SeqId",
"+",
"1",
"\n",
"}",
"\n",
"p",
".",
"Segments",
"[",
"p",
".",
"tail",
"]",
"=",
"seg",
"\n",
"p",
".",
"tail",
"=",
"(",
"p",
".",
"tail",
"+",
"1",
")",
"%",
"p",
".",
"capacity",
"\n",
"p",
".",
"count",
"++",
"\n",
"if",
"p",
".",
"TargetDuration",
"<",
"seg",
".",
"Duration",
"{",
"p",
".",
"TargetDuration",
"=",
"math",
".",
"Ceil",
"(",
"seg",
".",
"Duration",
")",
"\n",
"}",
"\n",
"p",
".",
"buf",
".",
"Reset",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
| // AppendSegment appends a MediaSegment to the tail of chunk slice for a media playlist.
// This operation does reset playlist cache. | [
"AppendSegment",
"appends",
"a",
"MediaSegment",
"to",
"the",
"tail",
"of",
"chunk",
"slice",
"for",
"a",
"media",
"playlist",
".",
"This",
"operation",
"does",
"reset",
"playlist",
"cache",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L324-L340 |
146,948 | grafov/m3u8 | writer.go | DurationAsInt | func (p *MediaPlaylist) DurationAsInt(yes bool) {
if yes {
// duration must be integers if protocol version is less than 3
version(&p.ver, 3)
}
p.durationAsInt = yes
} | go | func (p *MediaPlaylist) DurationAsInt(yes bool) {
if yes {
// duration must be integers if protocol version is less than 3
version(&p.ver, 3)
}
p.durationAsInt = yes
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"DurationAsInt",
"(",
"yes",
"bool",
")",
"{",
"if",
"yes",
"{",
"// duration must be integers if protocol version is less than 3",
"version",
"(",
"&",
"p",
".",
"ver",
",",
"3",
")",
"\n",
"}",
"\n",
"p",
".",
"durationAsInt",
"=",
"yes",
"\n",
"}"
]
| // TargetDuration will be int on Encode | [
"TargetDuration",
"will",
"be",
"int",
"on",
"Encode"
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L655-L661 |
146,949 | grafov/m3u8 | writer.go | Close | func (p *MediaPlaylist) Close() {
if p.buf.Len() > 0 {
p.buf.WriteString("#EXT-X-ENDLIST\n")
}
p.Closed = true
} | go | func (p *MediaPlaylist) Close() {
if p.buf.Len() > 0 {
p.buf.WriteString("#EXT-X-ENDLIST\n")
}
p.Closed = true
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"Close",
"(",
")",
"{",
"if",
"p",
".",
"buf",
".",
"Len",
"(",
")",
">",
"0",
"{",
"p",
".",
"buf",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"p",
".",
"Closed",
"=",
"true",
"\n",
"}"
]
| // Close sliding playlist and make them fixed. | [
"Close",
"sliding",
"playlist",
"and",
"make",
"them",
"fixed",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L669-L674 |
146,950 | grafov/m3u8 | writer.go | SetSCTE35 | func (p *MediaPlaylist) SetSCTE35(scte35 *SCTE) error {
if p.count == 0 {
return errors.New("playlist is empty")
}
p.Segments[p.last()].SCTE = scte35
return nil
} | go | func (p *MediaPlaylist) SetSCTE35(scte35 *SCTE) error {
if p.count == 0 {
return errors.New("playlist is empty")
}
p.Segments[p.last()].SCTE = scte35
return nil
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"SetSCTE35",
"(",
"scte35",
"*",
"SCTE",
")",
"error",
"{",
"if",
"p",
".",
"count",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"p",
".",
"Segments",
"[",
"p",
".",
"last",
"(",
")",
"]",
".",
"SCTE",
"=",
"scte35",
"\n",
"return",
"nil",
"\n",
"}"
]
| // SetSCTE35 sets the SCTE cue format for the current media segment | [
"SetSCTE35",
"sets",
"the",
"SCTE",
"cue",
"format",
"for",
"the",
"current",
"media",
"segment"
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L751-L757 |
146,951 | grafov/m3u8 | writer.go | SetWinSize | func (p *MediaPlaylist) SetWinSize(winsize uint) error {
if winsize > p.capacity {
return errors.New("capacity must be greater than winsize or equal")
}
p.winsize = winsize
return nil
} | go | func (p *MediaPlaylist) SetWinSize(winsize uint) error {
if winsize > p.capacity {
return errors.New("capacity must be greater than winsize or equal")
}
p.winsize = winsize
return nil
} | [
"func",
"(",
"p",
"*",
"MediaPlaylist",
")",
"SetWinSize",
"(",
"winsize",
"uint",
")",
"error",
"{",
"if",
"winsize",
">",
"p",
".",
"capacity",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"p",
".",
"winsize",
"=",
"winsize",
"\n",
"return",
"nil",
"\n",
"}"
]
| // SetWinSize overwrites the playlist's window size. | [
"SetWinSize",
"overwrites",
"the",
"playlist",
"s",
"window",
"size",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/writer.go#L801-L807 |
146,952 | grafov/m3u8 | reader.go | Decode | func (p *MasterPlaylist) Decode(data bytes.Buffer, strict bool) error {
return p.decode(&data, strict)
} | go | func (p *MasterPlaylist) Decode(data bytes.Buffer, strict bool) error {
return p.decode(&data, strict)
} | [
"func",
"(",
"p",
"*",
"MasterPlaylist",
")",
"Decode",
"(",
"data",
"bytes",
".",
"Buffer",
",",
"strict",
"bool",
")",
"error",
"{",
"return",
"p",
".",
"decode",
"(",
"&",
"data",
",",
"strict",
")",
"\n",
"}"
]
| // Decode parses a master playlist passed from the buffer. If `strict`
// parameter is true then it returns first syntax error. | [
"Decode",
"parses",
"a",
"master",
"playlist",
"passed",
"from",
"the",
"buffer",
".",
"If",
"strict",
"parameter",
"is",
"true",
"then",
"it",
"returns",
"first",
"syntax",
"error",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/reader.go#L35-L37 |
146,953 | grafov/m3u8 | reader.go | decode | func (p *MasterPlaylist) decode(buf *bytes.Buffer, strict bool) error {
var eof bool
state := new(decodingState)
for !eof {
line, err := buf.ReadString('\n')
if err == io.EOF {
eof = true
} else if err != nil {
break
}
err = decodeLineOfMasterPlaylist(p, state, line, strict)
if strict && err != nil {
return err
}
}
if strict && !state.m3u {
return errors.New("#EXTM3U absent")
}
return nil
} | go | func (p *MasterPlaylist) decode(buf *bytes.Buffer, strict bool) error {
var eof bool
state := new(decodingState)
for !eof {
line, err := buf.ReadString('\n')
if err == io.EOF {
eof = true
} else if err != nil {
break
}
err = decodeLineOfMasterPlaylist(p, state, line, strict)
if strict && err != nil {
return err
}
}
if strict && !state.m3u {
return errors.New("#EXTM3U absent")
}
return nil
} | [
"func",
"(",
"p",
"*",
"MasterPlaylist",
")",
"decode",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"strict",
"bool",
")",
"error",
"{",
"var",
"eof",
"bool",
"\n\n",
"state",
":=",
"new",
"(",
"decodingState",
")",
"\n\n",
"for",
"!",
"eof",
"{",
"line",
",",
"err",
":=",
"buf",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"eof",
"=",
"true",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"err",
"=",
"decodeLineOfMasterPlaylist",
"(",
"p",
",",
"state",
",",
"line",
",",
"strict",
")",
"\n",
"if",
"strict",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"strict",
"&&",
"!",
"state",
".",
"m3u",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
| // Parse master playlist. Internal function. | [
"Parse",
"master",
"playlist",
".",
"Internal",
"function",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/reader.go#L52-L73 |
146,954 | grafov/m3u8 | reader.go | Decode | func Decode(data bytes.Buffer, strict bool) (Playlist, ListType, error) {
return decode(&data, strict)
} | go | func Decode(data bytes.Buffer, strict bool) (Playlist, ListType, error) {
return decode(&data, strict)
} | [
"func",
"Decode",
"(",
"data",
"bytes",
".",
"Buffer",
",",
"strict",
"bool",
")",
"(",
"Playlist",
",",
"ListType",
",",
"error",
")",
"{",
"return",
"decode",
"(",
"&",
"data",
",",
"strict",
")",
"\n",
"}"
]
| // Decode detects type of playlist and decodes it. It accepts bytes
// buffer as input. | [
"Decode",
"detects",
"type",
"of",
"playlist",
"and",
"decodes",
"it",
".",
"It",
"accepts",
"bytes",
"buffer",
"as",
"input",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/reader.go#L125-L127 |
146,955 | grafov/m3u8 | reader.go | DecodeFrom | func DecodeFrom(reader io.Reader, strict bool) (Playlist, ListType, error) {
buf := new(bytes.Buffer)
_, err := buf.ReadFrom(reader)
if err != nil {
return nil, 0, err
}
return decode(buf, strict)
} | go | func DecodeFrom(reader io.Reader, strict bool) (Playlist, ListType, error) {
buf := new(bytes.Buffer)
_, err := buf.ReadFrom(reader)
if err != nil {
return nil, 0, err
}
return decode(buf, strict)
} | [
"func",
"DecodeFrom",
"(",
"reader",
"io",
".",
"Reader",
",",
"strict",
"bool",
")",
"(",
"Playlist",
",",
"ListType",
",",
"error",
")",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"_",
",",
"err",
":=",
"buf",
".",
"ReadFrom",
"(",
"reader",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"decode",
"(",
"buf",
",",
"strict",
")",
"\n",
"}"
]
| // DecodeFrom detects type of playlist and decodes it. It accepts data
// conformed with io.Reader. | [
"DecodeFrom",
"detects",
"type",
"of",
"playlist",
"and",
"decodes",
"it",
".",
"It",
"accepts",
"data",
"conformed",
"with",
"io",
".",
"Reader",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/reader.go#L131-L138 |
146,956 | grafov/m3u8 | reader.go | decode | func decode(buf *bytes.Buffer, strict bool) (Playlist, ListType, error) {
var eof bool
var line string
var master *MasterPlaylist
var media *MediaPlaylist
var listType ListType
var err error
state := new(decodingState)
wv := new(WV)
master = NewMasterPlaylist()
media, err = NewMediaPlaylist(8, 1024) // Winsize for VoD will become 0, capacity auto extends
if err != nil {
return nil, 0, fmt.Errorf("Create media playlist failed: %s", err)
}
for !eof {
if line, err = buf.ReadString('\n'); err == io.EOF {
eof = true
} else if err != nil {
break
}
// fixes the issues https://github.com/grafov/m3u8/issues/25
// TODO: the same should be done in decode functions of both Master- and MediaPlaylists
// so some DRYing would be needed.
if len(line) < 1 || line == "\r" {
continue
}
err = decodeLineOfMasterPlaylist(master, state, line, strict)
if strict && err != nil {
return master, state.listType, err
}
err = decodeLineOfMediaPlaylist(media, wv, state, line, strict)
if strict && err != nil {
return media, state.listType, err
}
}
if state.listType == MEDIA && state.tagWV {
media.WV = wv
}
if strict && !state.m3u {
return nil, listType, errors.New("#EXTM3U absent")
}
switch state.listType {
case MASTER:
return master, MASTER, nil
case MEDIA:
if media.Closed || media.MediaType == EVENT {
// VoD and Event's should show the entire playlist
media.SetWinSize(0)
}
return media, MEDIA, nil
}
return nil, state.listType, errors.New("Can't detect playlist type")
} | go | func decode(buf *bytes.Buffer, strict bool) (Playlist, ListType, error) {
var eof bool
var line string
var master *MasterPlaylist
var media *MediaPlaylist
var listType ListType
var err error
state := new(decodingState)
wv := new(WV)
master = NewMasterPlaylist()
media, err = NewMediaPlaylist(8, 1024) // Winsize for VoD will become 0, capacity auto extends
if err != nil {
return nil, 0, fmt.Errorf("Create media playlist failed: %s", err)
}
for !eof {
if line, err = buf.ReadString('\n'); err == io.EOF {
eof = true
} else if err != nil {
break
}
// fixes the issues https://github.com/grafov/m3u8/issues/25
// TODO: the same should be done in decode functions of both Master- and MediaPlaylists
// so some DRYing would be needed.
if len(line) < 1 || line == "\r" {
continue
}
err = decodeLineOfMasterPlaylist(master, state, line, strict)
if strict && err != nil {
return master, state.listType, err
}
err = decodeLineOfMediaPlaylist(media, wv, state, line, strict)
if strict && err != nil {
return media, state.listType, err
}
}
if state.listType == MEDIA && state.tagWV {
media.WV = wv
}
if strict && !state.m3u {
return nil, listType, errors.New("#EXTM3U absent")
}
switch state.listType {
case MASTER:
return master, MASTER, nil
case MEDIA:
if media.Closed || media.MediaType == EVENT {
// VoD and Event's should show the entire playlist
media.SetWinSize(0)
}
return media, MEDIA, nil
}
return nil, state.listType, errors.New("Can't detect playlist type")
} | [
"func",
"decode",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"strict",
"bool",
")",
"(",
"Playlist",
",",
"ListType",
",",
"error",
")",
"{",
"var",
"eof",
"bool",
"\n",
"var",
"line",
"string",
"\n",
"var",
"master",
"*",
"MasterPlaylist",
"\n",
"var",
"media",
"*",
"MediaPlaylist",
"\n",
"var",
"listType",
"ListType",
"\n",
"var",
"err",
"error",
"\n\n",
"state",
":=",
"new",
"(",
"decodingState",
")",
"\n",
"wv",
":=",
"new",
"(",
"WV",
")",
"\n\n",
"master",
"=",
"NewMasterPlaylist",
"(",
")",
"\n",
"media",
",",
"err",
"=",
"NewMediaPlaylist",
"(",
"8",
",",
"1024",
")",
"// Winsize for VoD will become 0, capacity auto extends",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"for",
"!",
"eof",
"{",
"if",
"line",
",",
"err",
"=",
"buf",
".",
"ReadString",
"(",
"'\\n'",
")",
";",
"err",
"==",
"io",
".",
"EOF",
"{",
"eof",
"=",
"true",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"// fixes the issues https://github.com/grafov/m3u8/issues/25",
"// TODO: the same should be done in decode functions of both Master- and MediaPlaylists",
"// so some DRYing would be needed.",
"if",
"len",
"(",
"line",
")",
"<",
"1",
"||",
"line",
"==",
"\"",
"\\r",
"\"",
"{",
"continue",
"\n",
"}",
"\n\n",
"err",
"=",
"decodeLineOfMasterPlaylist",
"(",
"master",
",",
"state",
",",
"line",
",",
"strict",
")",
"\n",
"if",
"strict",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"master",
",",
"state",
".",
"listType",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"decodeLineOfMediaPlaylist",
"(",
"media",
",",
"wv",
",",
"state",
",",
"line",
",",
"strict",
")",
"\n",
"if",
"strict",
"&&",
"err",
"!=",
"nil",
"{",
"return",
"media",
",",
"state",
".",
"listType",
",",
"err",
"\n",
"}",
"\n\n",
"}",
"\n",
"if",
"state",
".",
"listType",
"==",
"MEDIA",
"&&",
"state",
".",
"tagWV",
"{",
"media",
".",
"WV",
"=",
"wv",
"\n",
"}",
"\n\n",
"if",
"strict",
"&&",
"!",
"state",
".",
"m3u",
"{",
"return",
"nil",
",",
"listType",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"switch",
"state",
".",
"listType",
"{",
"case",
"MASTER",
":",
"return",
"master",
",",
"MASTER",
",",
"nil",
"\n",
"case",
"MEDIA",
":",
"if",
"media",
".",
"Closed",
"||",
"media",
".",
"MediaType",
"==",
"EVENT",
"{",
"// VoD and Event's should show the entire playlist",
"media",
".",
"SetWinSize",
"(",
"0",
")",
"\n",
"}",
"\n",
"return",
"media",
",",
"MEDIA",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"state",
".",
"listType",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
]
| // Detect playlist type and decode it. May be used as decoder for both
// master and media playlists. | [
"Detect",
"playlist",
"type",
"and",
"decode",
"it",
".",
"May",
"be",
"used",
"as",
"decoder",
"for",
"both",
"master",
"and",
"media",
"playlists",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/reader.go#L142-L203 |
146,957 | grafov/m3u8 | reader.go | StrictTimeParse | func StrictTimeParse(value string) (time.Time, error) {
return time.Parse(DATETIME, value)
} | go | func StrictTimeParse(value string) (time.Time, error) {
return time.Parse(DATETIME, value)
} | [
"func",
"StrictTimeParse",
"(",
"value",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"return",
"time",
".",
"Parse",
"(",
"DATETIME",
",",
"value",
")",
"\n",
"}"
]
| // StrictTimeParse implements RFC3339 with Nanoseconds accuracy. | [
"StrictTimeParse",
"implements",
"RFC3339",
"with",
"Nanoseconds",
"accuracy",
"."
]
| 1d88be54fa785021109edc0bd1a65518cec073a9 | https://github.com/grafov/m3u8/blob/1d88be54fa785021109edc0bd1a65518cec073a9/reader.go#L712-L714 |
146,958 | envoyproxy/go-control-plane | envoy/config/rbac/v2alpha/rbac.pb.validate.go | Validate | func (m *Policy) Validate() error {
if m == nil {
return nil
}
if len(m.GetPermissions()) < 1 {
return PolicyValidationError{
field: "Permissions",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetPermissions() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return PolicyValidationError{
field: fmt.Sprintf("Permissions[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
if len(m.GetPrincipals()) < 1 {
return PolicyValidationError{
field: "Principals",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetPrincipals() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return PolicyValidationError{
field: fmt.Sprintf("Principals[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *Policy) Validate() error {
if m == nil {
return nil
}
if len(m.GetPermissions()) < 1 {
return PolicyValidationError{
field: "Permissions",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetPermissions() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return PolicyValidationError{
field: fmt.Sprintf("Permissions[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
if len(m.GetPrincipals()) < 1 {
return PolicyValidationError{
field: "Principals",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetPrincipals() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return PolicyValidationError{
field: fmt.Sprintf("Principals[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Policy",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetPermissions",
"(",
")",
")",
"<",
"1",
"{",
"return",
"PolicyValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetPermissions",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"PolicyValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetPrincipals",
"(",
")",
")",
"<",
"1",
"{",
"return",
"PolicyValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetPrincipals",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"PolicyValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Policy with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Policy",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/rbac/v2alpha/rbac.pb.validate.go#L106-L166 |
146,959 | envoyproxy/go-control-plane | envoy/config/rbac/v2alpha/rbac.pb.validate.go | Validate | func (m *Permission_Set) Validate() error {
if m == nil {
return nil
}
if len(m.GetRules()) < 1 {
return Permission_SetValidationError{
field: "Rules",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetRules() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Permission_SetValidationError{
field: fmt.Sprintf("Rules[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *Permission_Set) Validate() error {
if m == nil {
return nil
}
if len(m.GetRules()) < 1 {
return Permission_SetValidationError{
field: "Rules",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetRules() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Permission_SetValidationError{
field: fmt.Sprintf("Rules[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Permission_Set",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetRules",
"(",
")",
")",
"<",
"1",
"{",
"return",
"Permission_SetValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetRules",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Permission_SetValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Permission_Set with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Permission_Set",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/rbac/v2alpha/rbac.pb.validate.go#L638-L671 |
146,960 | envoyproxy/go-control-plane | envoy/config/rbac/v2alpha/rbac.pb.validate.go | Validate | func (m *Principal_Set) Validate() error {
if m == nil {
return nil
}
if len(m.GetIds()) < 1 {
return Principal_SetValidationError{
field: "Ids",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetIds() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Principal_SetValidationError{
field: fmt.Sprintf("Ids[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *Principal_Set) Validate() error {
if m == nil {
return nil
}
if len(m.GetIds()) < 1 {
return Principal_SetValidationError{
field: "Ids",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetIds() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Principal_SetValidationError{
field: fmt.Sprintf("Ids[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Principal_Set",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetIds",
"(",
")",
")",
"<",
"1",
"{",
"return",
"Principal_SetValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetIds",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Principal_SetValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Principal_Set with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Principal_Set",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/rbac/v2alpha/rbac.pb.validate.go#L730-L763 |
146,961 | envoyproxy/go-control-plane | envoy/config/rbac/v2alpha/rbac.pb.validate.go | Validate | func (m *Principal_Authenticated) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetPrincipalName()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Principal_AuthenticatedValidationError{
field: "PrincipalName",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *Principal_Authenticated) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetPrincipalName()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Principal_AuthenticatedValidationError{
field: "PrincipalName",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Principal_Authenticated",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetPrincipalName",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Principal_AuthenticatedValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Principal_Authenticated with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Principal_Authenticated",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/rbac/v2alpha/rbac.pb.validate.go#L822-L843 |
146,962 | envoyproxy/go-control-plane | envoy/admin/v2alpha/tap.pb.validate.go | Validate | func (m *TapRequest) Validate() error {
if m == nil {
return nil
}
if len(m.GetConfigId()) < 1 {
return TapRequestValidationError{
field: "ConfigId",
reason: "value length must be at least 1 bytes",
}
}
if m.GetTapConfig() == nil {
return TapRequestValidationError{
field: "TapConfig",
reason: "value is required",
}
}
{
tmp := m.GetTapConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TapRequestValidationError{
field: "TapConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *TapRequest) Validate() error {
if m == nil {
return nil
}
if len(m.GetConfigId()) < 1 {
return TapRequestValidationError{
field: "ConfigId",
reason: "value length must be at least 1 bytes",
}
}
if m.GetTapConfig() == nil {
return TapRequestValidationError{
field: "TapConfig",
reason: "value is required",
}
}
{
tmp := m.GetTapConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TapRequestValidationError{
field: "TapConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"TapRequest",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetConfigId",
"(",
")",
")",
"<",
"1",
"{",
"return",
"TapRequestValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"GetTapConfig",
"(",
")",
"==",
"nil",
"{",
"return",
"TapRequestValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetTapConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TapRequestValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on TapRequest with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"TapRequest",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/tap.pb.validate.go#L38-L73 |
146,963 | envoyproxy/go-control-plane | envoy/config/accesslog/v2/als.pb.validate.go | Validate | func (m *HttpGrpcAccessLogConfig) Validate() error {
if m == nil {
return nil
}
if m.GetCommonConfig() == nil {
return HttpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "value is required",
}
}
{
tmp := m.GetCommonConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return HttpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *HttpGrpcAccessLogConfig) Validate() error {
if m == nil {
return nil
}
if m.GetCommonConfig() == nil {
return HttpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "value is required",
}
}
{
tmp := m.GetCommonConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return HttpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"HttpGrpcAccessLogConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"GetCommonConfig",
"(",
")",
"==",
"nil",
"{",
"return",
"HttpGrpcAccessLogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetCommonConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"HttpGrpcAccessLogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on HttpGrpcAccessLogConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"HttpGrpcAccessLogConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/accesslog/v2/als.pb.validate.go#L39-L67 |
146,964 | envoyproxy/go-control-plane | envoy/config/accesslog/v2/als.pb.validate.go | Validate | func (m *TcpGrpcAccessLogConfig) Validate() error {
if m == nil {
return nil
}
if m.GetCommonConfig() == nil {
return TcpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "value is required",
}
}
{
tmp := m.GetCommonConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TcpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *TcpGrpcAccessLogConfig) Validate() error {
if m == nil {
return nil
}
if m.GetCommonConfig() == nil {
return TcpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "value is required",
}
}
{
tmp := m.GetCommonConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TcpGrpcAccessLogConfigValidationError{
field: "CommonConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"TcpGrpcAccessLogConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"GetCommonConfig",
"(",
")",
"==",
"nil",
"{",
"return",
"TcpGrpcAccessLogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetCommonConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TcpGrpcAccessLogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on TcpGrpcAccessLogConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"TcpGrpcAccessLogConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/accesslog/v2/als.pb.validate.go#L128-L156 |
146,965 | envoyproxy/go-control-plane | envoy/config/accesslog/v2/als.pb.validate.go | Validate | func (m *CommonGrpcAccessLogConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetLogName()) < 1 {
return CommonGrpcAccessLogConfigValidationError{
field: "LogName",
reason: "value length must be at least 1 bytes",
}
}
if m.GetGrpcService() == nil {
return CommonGrpcAccessLogConfigValidationError{
field: "GrpcService",
reason: "value is required",
}
}
{
tmp := m.GetGrpcService()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommonGrpcAccessLogConfigValidationError{
field: "GrpcService",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *CommonGrpcAccessLogConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetLogName()) < 1 {
return CommonGrpcAccessLogConfigValidationError{
field: "LogName",
reason: "value length must be at least 1 bytes",
}
}
if m.GetGrpcService() == nil {
return CommonGrpcAccessLogConfigValidationError{
field: "GrpcService",
reason: "value is required",
}
}
{
tmp := m.GetGrpcService()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommonGrpcAccessLogConfigValidationError{
field: "GrpcService",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"CommonGrpcAccessLogConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetLogName",
"(",
")",
")",
"<",
"1",
"{",
"return",
"CommonGrpcAccessLogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"GetGrpcService",
"(",
")",
"==",
"nil",
"{",
"return",
"CommonGrpcAccessLogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetGrpcService",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CommonGrpcAccessLogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on CommonGrpcAccessLogConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"CommonGrpcAccessLogConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/accesslog/v2/als.pb.validate.go#L217-L252 |
146,966 | envoyproxy/go-control-plane | envoy/service/auth/v2/attribute_context.pb.validate.go | Validate | func (m *AttributeContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetSource()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContextValidationError{
field: "Source",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetDestination()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContextValidationError{
field: "Destination",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequest()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContextValidationError{
field: "Request",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for ContextExtensions
return nil
} | go | func (m *AttributeContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetSource()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContextValidationError{
field: "Source",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetDestination()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContextValidationError{
field: "Destination",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequest()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContextValidationError{
field: "Request",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for ContextExtensions
return nil
} | [
"func",
"(",
"m",
"*",
"AttributeContext",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetSource",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"AttributeContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetDestination",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"AttributeContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetRequest",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"AttributeContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for ContextExtensions",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on AttributeContext with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"AttributeContext",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/auth/v2/attribute_context.pb.validate.go#L39-L92 |
146,967 | envoyproxy/go-control-plane | envoy/service/auth/v2/attribute_context.pb.validate.go | Validate | func (m *AttributeContext_Peer) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetAddress()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContext_PeerValidationError{
field: "Address",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for Service
// no validation rules for Labels
// no validation rules for Principal
return nil
} | go | func (m *AttributeContext_Peer) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetAddress()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContext_PeerValidationError{
field: "Address",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for Service
// no validation rules for Labels
// no validation rules for Principal
return nil
} | [
"func",
"(",
"m",
"*",
"AttributeContext_Peer",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetAddress",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"AttributeContext_PeerValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for Service",
"// no validation rules for Labels",
"// no validation rules for Principal",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on AttributeContext_Peer with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"AttributeContext_Peer",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/auth/v2/attribute_context.pb.validate.go#L151-L178 |
146,968 | envoyproxy/go-control-plane | envoy/service/auth/v2/attribute_context.pb.validate.go | Validate | func (m *AttributeContext_Request) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetTime()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContext_RequestValidationError{
field: "Time",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetHttp()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContext_RequestValidationError{
field: "Http",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *AttributeContext_Request) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetTime()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContext_RequestValidationError{
field: "Time",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetHttp()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return AttributeContext_RequestValidationError{
field: "Http",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"AttributeContext_Request",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetTime",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"AttributeContext_RequestValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetHttp",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"AttributeContext_RequestValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on AttributeContext_Request with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"AttributeContext_Request",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/auth/v2/attribute_context.pb.validate.go#L239-L275 |
146,969 | envoyproxy/go-control-plane | envoy/config/filter/http/transcoder/v2/transcoder.pb.validate.go | Validate | func (m *GrpcJsonTranscoder) Validate() error {
if m == nil {
return nil
}
if len(m.GetServices()) < 1 {
return GrpcJsonTranscoderValidationError{
field: "Services",
reason: "value must contain at least 1 item(s)",
}
}
{
tmp := m.GetPrintOptions()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return GrpcJsonTranscoderValidationError{
field: "PrintOptions",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for MatchIncomingRequestRoute
switch m.DescriptorSet.(type) {
case *GrpcJsonTranscoder_ProtoDescriptor:
// no validation rules for ProtoDescriptor
case *GrpcJsonTranscoder_ProtoDescriptorBin:
// no validation rules for ProtoDescriptorBin
default:
return GrpcJsonTranscoderValidationError{
field: "DescriptorSet",
reason: "value is required",
}
}
return nil
} | go | func (m *GrpcJsonTranscoder) Validate() error {
if m == nil {
return nil
}
if len(m.GetServices()) < 1 {
return GrpcJsonTranscoderValidationError{
field: "Services",
reason: "value must contain at least 1 item(s)",
}
}
{
tmp := m.GetPrintOptions()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return GrpcJsonTranscoderValidationError{
field: "PrintOptions",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for MatchIncomingRequestRoute
switch m.DescriptorSet.(type) {
case *GrpcJsonTranscoder_ProtoDescriptor:
// no validation rules for ProtoDescriptor
case *GrpcJsonTranscoder_ProtoDescriptorBin:
// no validation rules for ProtoDescriptorBin
default:
return GrpcJsonTranscoderValidationError{
field: "DescriptorSet",
reason: "value is required",
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"GrpcJsonTranscoder",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetServices",
"(",
")",
")",
"<",
"1",
"{",
"return",
"GrpcJsonTranscoderValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetPrintOptions",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"GrpcJsonTranscoderValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for MatchIncomingRequestRoute",
"switch",
"m",
".",
"DescriptorSet",
".",
"(",
"type",
")",
"{",
"case",
"*",
"GrpcJsonTranscoder_ProtoDescriptor",
":",
"// no validation rules for ProtoDescriptor",
"case",
"*",
"GrpcJsonTranscoder_ProtoDescriptorBin",
":",
"// no validation rules for ProtoDescriptorBin",
"default",
":",
"return",
"GrpcJsonTranscoderValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on GrpcJsonTranscoder with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"GrpcJsonTranscoder",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/http/transcoder/v2/transcoder.pb.validate.go#L39-L85 |
146,970 | envoyproxy/go-control-plane | envoy/service/metrics/v2/metrics_service.pb.validate.go | Validate | func (m *StreamMetricsMessage) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetIdentifier()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return StreamMetricsMessageValidationError{
field: "Identifier",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetEnvoyMetrics() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return StreamMetricsMessageValidationError{
field: fmt.Sprintf("EnvoyMetrics[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *StreamMetricsMessage) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetIdentifier()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return StreamMetricsMessageValidationError{
field: "Identifier",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetEnvoyMetrics() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return StreamMetricsMessageValidationError{
field: fmt.Sprintf("EnvoyMetrics[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"StreamMetricsMessage",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetIdentifier",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"StreamMetricsMessageValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetEnvoyMetrics",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"StreamMetricsMessageValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on StreamMetricsMessage with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"StreamMetricsMessage",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/metrics/v2/metrics_service.pb.validate.go#L106-L147 |
146,971 | envoyproxy/go-control-plane | envoy/service/metrics/v2/metrics_service.pb.validate.go | Validate | func (m *StreamMetricsMessage_Identifier) Validate() error {
if m == nil {
return nil
}
if m.GetNode() == nil {
return StreamMetricsMessage_IdentifierValidationError{
field: "Node",
reason: "value is required",
}
}
{
tmp := m.GetNode()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return StreamMetricsMessage_IdentifierValidationError{
field: "Node",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *StreamMetricsMessage_Identifier) Validate() error {
if m == nil {
return nil
}
if m.GetNode() == nil {
return StreamMetricsMessage_IdentifierValidationError{
field: "Node",
reason: "value is required",
}
}
{
tmp := m.GetNode()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return StreamMetricsMessage_IdentifierValidationError{
field: "Node",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"StreamMetricsMessage_Identifier",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"GetNode",
"(",
")",
"==",
"nil",
"{",
"return",
"StreamMetricsMessage_IdentifierValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetNode",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"StreamMetricsMessage_IdentifierValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on StreamMetricsMessage_Identifier with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"StreamMetricsMessage_Identifier",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/metrics/v2/metrics_service.pb.validate.go#L208-L236 |
146,972 | envoyproxy/go-control-plane | envoy/config/grpc_credential/v2alpha/file_based_metadata.pb.validate.go | Validate | func (m *FileBasedMetadataConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetSecretData()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return FileBasedMetadataConfigValidationError{
field: "SecretData",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for HeaderKey
// no validation rules for HeaderPrefix
return nil
} | go | func (m *FileBasedMetadataConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetSecretData()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return FileBasedMetadataConfigValidationError{
field: "SecretData",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for HeaderKey
// no validation rules for HeaderPrefix
return nil
} | [
"func",
"(",
"m",
"*",
"FileBasedMetadataConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetSecretData",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"FileBasedMetadataConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for HeaderKey",
"// no validation rules for HeaderPrefix",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on FileBasedMetadataConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"FileBasedMetadataConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/grpc_credential/v2alpha/file_based_metadata.pb.validate.go#L39-L64 |
146,973 | envoyproxy/go-control-plane | envoy/data/tap/v2alpha/wrapper.pb.validate.go | Validate | func (m *TraceWrapper) Validate() error {
if m == nil {
return nil
}
switch m.Trace.(type) {
case *TraceWrapper_HttpBufferedTrace:
{
tmp := m.GetHttpBufferedTrace()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "HttpBufferedTrace",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *TraceWrapper_HttpStreamedTraceSegment:
{
tmp := m.GetHttpStreamedTraceSegment()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "HttpStreamedTraceSegment",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *TraceWrapper_SocketBufferedTrace:
{
tmp := m.GetSocketBufferedTrace()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "SocketBufferedTrace",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *TraceWrapper_SocketStreamedTraceSegment:
{
tmp := m.GetSocketStreamedTraceSegment()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "SocketStreamedTraceSegment",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
default:
return TraceWrapperValidationError{
field: "Trace",
reason: "value is required",
}
}
return nil
} | go | func (m *TraceWrapper) Validate() error {
if m == nil {
return nil
}
switch m.Trace.(type) {
case *TraceWrapper_HttpBufferedTrace:
{
tmp := m.GetHttpBufferedTrace()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "HttpBufferedTrace",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *TraceWrapper_HttpStreamedTraceSegment:
{
tmp := m.GetHttpStreamedTraceSegment()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "HttpStreamedTraceSegment",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *TraceWrapper_SocketBufferedTrace:
{
tmp := m.GetSocketBufferedTrace()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "SocketBufferedTrace",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *TraceWrapper_SocketStreamedTraceSegment:
{
tmp := m.GetSocketStreamedTraceSegment()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceWrapperValidationError{
field: "SocketStreamedTraceSegment",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
default:
return TraceWrapperValidationError{
field: "Trace",
reason: "value is required",
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"TraceWrapper",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"switch",
"m",
".",
"Trace",
".",
"(",
"type",
")",
"{",
"case",
"*",
"TraceWrapper_HttpBufferedTrace",
":",
"{",
"tmp",
":=",
"m",
".",
"GetHttpBufferedTrace",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TraceWrapperValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"case",
"*",
"TraceWrapper_HttpStreamedTraceSegment",
":",
"{",
"tmp",
":=",
"m",
".",
"GetHttpStreamedTraceSegment",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TraceWrapperValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"case",
"*",
"TraceWrapper_SocketBufferedTrace",
":",
"{",
"tmp",
":=",
"m",
".",
"GetSocketBufferedTrace",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TraceWrapperValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"case",
"*",
"TraceWrapper_SocketStreamedTraceSegment",
":",
"{",
"tmp",
":=",
"m",
".",
"GetSocketStreamedTraceSegment",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TraceWrapperValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"default",
":",
"return",
"TraceWrapperValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on TraceWrapper with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"TraceWrapper",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/data/tap/v2alpha/wrapper.pb.validate.go#L39-L123 |
146,974 | envoyproxy/go-control-plane | envoy/api/v2/rds.pb.validate.go | Validate | func (m *RouteConfiguration) Validate() error {
if m == nil {
return nil
}
// no validation rules for Name
for idx, item := range m.GetVirtualHosts() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: fmt.Sprintf("VirtualHosts[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
{
tmp := m.GetVhds()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: "Vhds",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(m.GetResponseHeadersToAdd()) > 1000 {
return RouteConfigurationValidationError{
field: "ResponseHeadersToAdd",
reason: "value must contain no more than 1000 item(s)",
}
}
for idx, item := range m.GetResponseHeadersToAdd() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
if len(m.GetRequestHeadersToAdd()) > 1000 {
return RouteConfigurationValidationError{
field: "RequestHeadersToAdd",
reason: "value must contain no more than 1000 item(s)",
}
}
for idx, item := range m.GetRequestHeadersToAdd() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
{
tmp := m.GetValidateClusters()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: "ValidateClusters",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *RouteConfiguration) Validate() error {
if m == nil {
return nil
}
// no validation rules for Name
for idx, item := range m.GetVirtualHosts() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: fmt.Sprintf("VirtualHosts[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
{
tmp := m.GetVhds()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: "Vhds",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(m.GetResponseHeadersToAdd()) > 1000 {
return RouteConfigurationValidationError{
field: "ResponseHeadersToAdd",
reason: "value must contain no more than 1000 item(s)",
}
}
for idx, item := range m.GetResponseHeadersToAdd() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
if len(m.GetRequestHeadersToAdd()) > 1000 {
return RouteConfigurationValidationError{
field: "RequestHeadersToAdd",
reason: "value must contain no more than 1000 item(s)",
}
}
for idx, item := range m.GetRequestHeadersToAdd() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
{
tmp := m.GetValidateClusters()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return RouteConfigurationValidationError{
field: "ValidateClusters",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"RouteConfiguration",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// no validation rules for Name",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetVirtualHosts",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"&",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"RouteConfigurationValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetVhds",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"RouteConfigurationValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetResponseHeadersToAdd",
"(",
")",
")",
">",
"1000",
"{",
"return",
"RouteConfigurationValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetResponseHeadersToAdd",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"RouteConfigurationValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetRequestHeadersToAdd",
"(",
")",
")",
">",
"1000",
"{",
"return",
"RouteConfigurationValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetRequestHeadersToAdd",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"RouteConfigurationValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetValidateClusters",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"RouteConfigurationValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on RouteConfiguration with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"RouteConfiguration",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/rds.pb.validate.go#L39-L151 |
146,975 | envoyproxy/go-control-plane | envoy/api/v2/rds.pb.validate.go | Validate | func (m *Vhds) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetConfigSource()
if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return VhdsValidationError{
field: "ConfigSource",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *Vhds) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetConfigSource()
if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return VhdsValidationError{
field: "ConfigSource",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Vhds",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetConfigSource",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"&",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"VhdsValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Vhds with the rules defined in the proto
// definition for this message. If any rules are violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Vhds",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/rds.pb.validate.go#L211-L232 |
146,976 | envoyproxy/go-control-plane | envoy/admin/v2alpha/server_info.pb.validate.go | Validate | func (m *ServerInfo) Validate() error {
if m == nil {
return nil
}
// no validation rules for Version
// no validation rules for State
{
tmp := m.GetUptimeCurrentEpoch()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServerInfoValidationError{
field: "UptimeCurrentEpoch",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetUptimeAllEpochs()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServerInfoValidationError{
field: "UptimeAllEpochs",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetCommandLineOptions()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServerInfoValidationError{
field: "CommandLineOptions",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *ServerInfo) Validate() error {
if m == nil {
return nil
}
// no validation rules for Version
// no validation rules for State
{
tmp := m.GetUptimeCurrentEpoch()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServerInfoValidationError{
field: "UptimeCurrentEpoch",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetUptimeAllEpochs()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServerInfoValidationError{
field: "UptimeAllEpochs",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetCommandLineOptions()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ServerInfoValidationError{
field: "CommandLineOptions",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"ServerInfo",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// no validation rules for Version",
"// no validation rules for State",
"{",
"tmp",
":=",
"m",
".",
"GetUptimeCurrentEpoch",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ServerInfoValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetUptimeAllEpochs",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ServerInfoValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetCommandLineOptions",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ServerInfoValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on ServerInfo with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"ServerInfo",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/server_info.pb.validate.go#L38-L93 |
146,977 | envoyproxy/go-control-plane | envoy/admin/v2alpha/server_info.pb.validate.go | Validate | func (m *CommandLineOptions) Validate() error {
if m == nil {
return nil
}
// no validation rules for BaseId
// no validation rules for Concurrency
// no validation rules for ConfigPath
// no validation rules for ConfigYaml
// no validation rules for AllowUnknownFields
// no validation rules for AdminAddressPath
// no validation rules for LocalAddressIpVersion
// no validation rules for LogLevel
// no validation rules for ComponentLogLevel
// no validation rules for LogFormat
// no validation rules for LogPath
// no validation rules for HotRestartVersion
// no validation rules for ServiceCluster
// no validation rules for ServiceNode
// no validation rules for ServiceZone
{
tmp := m.GetFileFlushInterval()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommandLineOptionsValidationError{
field: "FileFlushInterval",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetDrainTime()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommandLineOptionsValidationError{
field: "DrainTime",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetParentShutdownTime()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommandLineOptionsValidationError{
field: "ParentShutdownTime",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for Mode
// no validation rules for MaxStats
// no validation rules for MaxObjNameLen
// no validation rules for DisableHotRestart
// no validation rules for EnableMutexTracing
// no validation rules for RestartEpoch
// no validation rules for CpusetThreads
return nil
} | go | func (m *CommandLineOptions) Validate() error {
if m == nil {
return nil
}
// no validation rules for BaseId
// no validation rules for Concurrency
// no validation rules for ConfigPath
// no validation rules for ConfigYaml
// no validation rules for AllowUnknownFields
// no validation rules for AdminAddressPath
// no validation rules for LocalAddressIpVersion
// no validation rules for LogLevel
// no validation rules for ComponentLogLevel
// no validation rules for LogFormat
// no validation rules for LogPath
// no validation rules for HotRestartVersion
// no validation rules for ServiceCluster
// no validation rules for ServiceNode
// no validation rules for ServiceZone
{
tmp := m.GetFileFlushInterval()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommandLineOptionsValidationError{
field: "FileFlushInterval",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetDrainTime()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommandLineOptionsValidationError{
field: "DrainTime",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetParentShutdownTime()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CommandLineOptionsValidationError{
field: "ParentShutdownTime",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for Mode
// no validation rules for MaxStats
// no validation rules for MaxObjNameLen
// no validation rules for DisableHotRestart
// no validation rules for EnableMutexTracing
// no validation rules for RestartEpoch
// no validation rules for CpusetThreads
return nil
} | [
"func",
"(",
"m",
"*",
"CommandLineOptions",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// no validation rules for BaseId",
"// no validation rules for Concurrency",
"// no validation rules for ConfigPath",
"// no validation rules for ConfigYaml",
"// no validation rules for AllowUnknownFields",
"// no validation rules for AdminAddressPath",
"// no validation rules for LocalAddressIpVersion",
"// no validation rules for LogLevel",
"// no validation rules for ComponentLogLevel",
"// no validation rules for LogFormat",
"// no validation rules for LogPath",
"// no validation rules for HotRestartVersion",
"// no validation rules for ServiceCluster",
"// no validation rules for ServiceNode",
"// no validation rules for ServiceZone",
"{",
"tmp",
":=",
"m",
".",
"GetFileFlushInterval",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CommandLineOptionsValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetDrainTime",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CommandLineOptionsValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetParentShutdownTime",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CommandLineOptionsValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for Mode",
"// no validation rules for MaxStats",
"// no validation rules for MaxObjNameLen",
"// no validation rules for DisableHotRestart",
"// no validation rules for EnableMutexTracing",
"// no validation rules for RestartEpoch",
"// no validation rules for CpusetThreads",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on CommandLineOptions with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"CommandLineOptions",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/server_info.pb.validate.go#L152-L247 |
146,978 | envoyproxy/go-control-plane | envoy/config/trace/v2/trace.pb.validate.go | Validate | func (m *Tracing) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetHttp()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TracingValidationError{
field: "Http",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *Tracing) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetHttp()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TracingValidationError{
field: "Http",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Tracing",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetHttp",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TracingValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Tracing with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Tracing",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/trace/v2/trace.pb.validate.go#L38-L59 |
146,979 | envoyproxy/go-control-plane | envoy/config/trace/v2/trace.pb.validate.go | Validate | func (m *LightstepConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetCollectorCluster()) < 1 {
return LightstepConfigValidationError{
field: "CollectorCluster",
reason: "value length must be at least 1 bytes",
}
}
if len(m.GetAccessTokenFile()) < 1 {
return LightstepConfigValidationError{
field: "AccessTokenFile",
reason: "value length must be at least 1 bytes",
}
}
return nil
} | go | func (m *LightstepConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetCollectorCluster()) < 1 {
return LightstepConfigValidationError{
field: "CollectorCluster",
reason: "value length must be at least 1 bytes",
}
}
if len(m.GetAccessTokenFile()) < 1 {
return LightstepConfigValidationError{
field: "AccessTokenFile",
reason: "value length must be at least 1 bytes",
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"LightstepConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetCollectorCluster",
"(",
")",
")",
"<",
"1",
"{",
"return",
"LightstepConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetAccessTokenFile",
"(",
")",
")",
"<",
"1",
"{",
"return",
"LightstepConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on LightstepConfig with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"LightstepConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/trace/v2/trace.pb.validate.go#L118-L138 |
146,980 | envoyproxy/go-control-plane | envoy/config/trace/v2/trace.pb.validate.go | Validate | func (m *ZipkinConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetCollectorCluster()) < 1 {
return ZipkinConfigValidationError{
field: "CollectorCluster",
reason: "value length must be at least 1 bytes",
}
}
if len(m.GetCollectorEndpoint()) < 1 {
return ZipkinConfigValidationError{
field: "CollectorEndpoint",
reason: "value length must be at least 1 bytes",
}
}
// no validation rules for TraceId_128Bit
{
tmp := m.GetSharedSpanContext()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ZipkinConfigValidationError{
field: "SharedSpanContext",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *ZipkinConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetCollectorCluster()) < 1 {
return ZipkinConfigValidationError{
field: "CollectorCluster",
reason: "value length must be at least 1 bytes",
}
}
if len(m.GetCollectorEndpoint()) < 1 {
return ZipkinConfigValidationError{
field: "CollectorEndpoint",
reason: "value length must be at least 1 bytes",
}
}
// no validation rules for TraceId_128Bit
{
tmp := m.GetSharedSpanContext()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return ZipkinConfigValidationError{
field: "SharedSpanContext",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"ZipkinConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetCollectorCluster",
"(",
")",
")",
"<",
"1",
"{",
"return",
"ZipkinConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetCollectorEndpoint",
"(",
")",
")",
"<",
"1",
"{",
"return",
"ZipkinConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for TraceId_128Bit",
"{",
"tmp",
":=",
"m",
".",
"GetSharedSpanContext",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ZipkinConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on ZipkinConfig with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"ZipkinConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/trace/v2/trace.pb.validate.go#L197-L234 |
146,981 | envoyproxy/go-control-plane | envoy/config/trace/v2/trace.pb.validate.go | Validate | func (m *DynamicOtConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetLibrary()) < 1 {
return DynamicOtConfigValidationError{
field: "Library",
reason: "value length must be at least 1 bytes",
}
}
{
tmp := m.GetConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DynamicOtConfigValidationError{
field: "Config",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *DynamicOtConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetLibrary()) < 1 {
return DynamicOtConfigValidationError{
field: "Library",
reason: "value length must be at least 1 bytes",
}
}
{
tmp := m.GetConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DynamicOtConfigValidationError{
field: "Config",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"DynamicOtConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetLibrary",
"(",
")",
")",
"<",
"1",
"{",
"return",
"DynamicOtConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"DynamicOtConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on DynamicOtConfig with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"DynamicOtConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/trace/v2/trace.pb.validate.go#L293-L321 |
146,982 | envoyproxy/go-control-plane | envoy/config/trace/v2/trace.pb.validate.go | Validate | func (m *DatadogConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetCollectorCluster()) < 1 {
return DatadogConfigValidationError{
field: "CollectorCluster",
reason: "value length must be at least 1 bytes",
}
}
if len(m.GetServiceName()) < 1 {
return DatadogConfigValidationError{
field: "ServiceName",
reason: "value length must be at least 1 bytes",
}
}
return nil
} | go | func (m *DatadogConfig) Validate() error {
if m == nil {
return nil
}
if len(m.GetCollectorCluster()) < 1 {
return DatadogConfigValidationError{
field: "CollectorCluster",
reason: "value length must be at least 1 bytes",
}
}
if len(m.GetServiceName()) < 1 {
return DatadogConfigValidationError{
field: "ServiceName",
reason: "value length must be at least 1 bytes",
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"DatadogConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetCollectorCluster",
"(",
")",
")",
"<",
"1",
"{",
"return",
"DatadogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetServiceName",
"(",
")",
")",
"<",
"1",
"{",
"return",
"DatadogConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on DatadogConfig with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"DatadogConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/trace/v2/trace.pb.validate.go#L380-L400 |
146,983 | envoyproxy/go-control-plane | envoy/config/trace/v2/trace.pb.validate.go | Validate | func (m *TraceServiceConfig) Validate() error {
if m == nil {
return nil
}
if m.GetGrpcService() == nil {
return TraceServiceConfigValidationError{
field: "GrpcService",
reason: "value is required",
}
}
{
tmp := m.GetGrpcService()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceServiceConfigValidationError{
field: "GrpcService",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *TraceServiceConfig) Validate() error {
if m == nil {
return nil
}
if m.GetGrpcService() == nil {
return TraceServiceConfigValidationError{
field: "GrpcService",
reason: "value is required",
}
}
{
tmp := m.GetGrpcService()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TraceServiceConfigValidationError{
field: "GrpcService",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"TraceServiceConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"GetGrpcService",
"(",
")",
"==",
"nil",
"{",
"return",
"TraceServiceConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetGrpcService",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TraceServiceConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on TraceServiceConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"TraceServiceConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/trace/v2/trace.pb.validate.go#L459-L487 |
146,984 | envoyproxy/go-control-plane | envoy/config/trace/v2/trace.pb.validate.go | Validate | func (m *Tracing_Http) Validate() error {
if m == nil {
return nil
}
if len(m.GetName()) < 1 {
return Tracing_HttpValidationError{
field: "Name",
reason: "value length must be at least 1 bytes",
}
}
switch m.ConfigType.(type) {
case *Tracing_Http_Config:
{
tmp := m.GetConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Tracing_HttpValidationError{
field: "Config",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *Tracing_Http_TypedConfig:
{
tmp := m.GetTypedConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Tracing_HttpValidationError{
field: "TypedConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *Tracing_Http) Validate() error {
if m == nil {
return nil
}
if len(m.GetName()) < 1 {
return Tracing_HttpValidationError{
field: "Name",
reason: "value length must be at least 1 bytes",
}
}
switch m.ConfigType.(type) {
case *Tracing_Http_Config:
{
tmp := m.GetConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Tracing_HttpValidationError{
field: "Config",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *Tracing_Http_TypedConfig:
{
tmp := m.GetTypedConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Tracing_HttpValidationError{
field: "TypedConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Tracing_Http",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetName",
"(",
")",
")",
"<",
"1",
"{",
"return",
"Tracing_HttpValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"switch",
"m",
".",
"ConfigType",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Tracing_Http_Config",
":",
"{",
"tmp",
":=",
"m",
".",
"GetConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Tracing_HttpValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"case",
"*",
"Tracing_Http_TypedConfig",
":",
"{",
"tmp",
":=",
"m",
".",
"GetTypedConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Tracing_HttpValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Tracing_Http with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Tracing_Http",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/trace/v2/trace.pb.validate.go#L548-L599 |
146,985 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *UpstreamBindConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetSourceAddress()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamBindConfigValidationError{
field: "SourceAddress",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *UpstreamBindConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetSourceAddress()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamBindConfigValidationError{
field: "SourceAddress",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"UpstreamBindConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetSourceAddress",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"UpstreamBindConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on UpstreamBindConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"UpstreamBindConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L563-L584 |
146,986 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *UpstreamConnectionOptions) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetTcpKeepalive()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamConnectionOptionsValidationError{
field: "TcpKeepalive",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *UpstreamConnectionOptions) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetTcpKeepalive()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamConnectionOptionsValidationError{
field: "TcpKeepalive",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"UpstreamConnectionOptions",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetTcpKeepalive",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"UpstreamConnectionOptionsValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on UpstreamConnectionOptions with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"UpstreamConnectionOptions",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L645-L666 |
146,987 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *Cluster_CustomClusterType) Validate() error {
if m == nil {
return nil
}
if len(m.GetName()) < 1 {
return Cluster_CustomClusterTypeValidationError{
field: "Name",
reason: "value length must be at least 1 bytes",
}
}
{
tmp := m.GetTypedConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CustomClusterTypeValidationError{
field: "TypedConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *Cluster_CustomClusterType) Validate() error {
if m == nil {
return nil
}
if len(m.GetName()) < 1 {
return Cluster_CustomClusterTypeValidationError{
field: "Name",
reason: "value length must be at least 1 bytes",
}
}
{
tmp := m.GetTypedConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CustomClusterTypeValidationError{
field: "TypedConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Cluster_CustomClusterType",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetName",
"(",
")",
")",
"<",
"1",
"{",
"return",
"Cluster_CustomClusterTypeValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetTypedConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_CustomClusterTypeValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Cluster_CustomClusterType with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Cluster_CustomClusterType",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L727-L755 |
146,988 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *Cluster_EdsClusterConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetEdsConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_EdsClusterConfigValidationError{
field: "EdsConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for ServiceName
return nil
} | go | func (m *Cluster_EdsClusterConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetEdsConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_EdsClusterConfigValidationError{
field: "EdsConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for ServiceName
return nil
} | [
"func",
"(",
"m",
"*",
"Cluster_EdsClusterConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetEdsConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_EdsClusterConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for ServiceName",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Cluster_EdsClusterConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Cluster_EdsClusterConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L816-L839 |
146,989 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *Cluster_LbSubsetConfig) Validate() error {
if m == nil {
return nil
}
if _, ok := Cluster_LbSubsetConfig_LbSubsetFallbackPolicy_name[int32(m.GetFallbackPolicy())]; !ok {
return Cluster_LbSubsetConfigValidationError{
field: "FallbackPolicy",
reason: "value must be one of the defined enum values",
}
}
{
tmp := m.GetDefaultSubset()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_LbSubsetConfigValidationError{
field: "DefaultSubset",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetSubsetSelectors() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_LbSubsetConfigValidationError{
field: fmt.Sprintf("SubsetSelectors[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
// no validation rules for LocalityWeightAware
// no validation rules for ScaleLocalityWeight
// no validation rules for PanicModeAny
return nil
} | go | func (m *Cluster_LbSubsetConfig) Validate() error {
if m == nil {
return nil
}
if _, ok := Cluster_LbSubsetConfig_LbSubsetFallbackPolicy_name[int32(m.GetFallbackPolicy())]; !ok {
return Cluster_LbSubsetConfigValidationError{
field: "FallbackPolicy",
reason: "value must be one of the defined enum values",
}
}
{
tmp := m.GetDefaultSubset()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_LbSubsetConfigValidationError{
field: "DefaultSubset",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetSubsetSelectors() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_LbSubsetConfigValidationError{
field: fmt.Sprintf("SubsetSelectors[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
// no validation rules for LocalityWeightAware
// no validation rules for ScaleLocalityWeight
// no validation rules for PanicModeAny
return nil
} | [
"func",
"(",
"m",
"*",
"Cluster_LbSubsetConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"Cluster_LbSubsetConfig_LbSubsetFallbackPolicy_name",
"[",
"int32",
"(",
"m",
".",
"GetFallbackPolicy",
"(",
")",
")",
"]",
";",
"!",
"ok",
"{",
"return",
"Cluster_LbSubsetConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetDefaultSubset",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_LbSubsetConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetSubsetSelectors",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_LbSubsetConfigValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"// no validation rules for LocalityWeightAware",
"// no validation rules for ScaleLocalityWeight",
"// no validation rules for PanicModeAny",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Cluster_LbSubsetConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Cluster_LbSubsetConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L900-L954 |
146,990 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *Cluster_LeastRequestLbConfig) Validate() error {
if m == nil {
return nil
}
if wrapper := m.GetChoiceCount(); wrapper != nil {
if wrapper.GetValue() < 2 {
return Cluster_LeastRequestLbConfigValidationError{
field: "ChoiceCount",
reason: "value must be greater than or equal to 2",
}
}
}
return nil
} | go | func (m *Cluster_LeastRequestLbConfig) Validate() error {
if m == nil {
return nil
}
if wrapper := m.GetChoiceCount(); wrapper != nil {
if wrapper.GetValue() < 2 {
return Cluster_LeastRequestLbConfigValidationError{
field: "ChoiceCount",
reason: "value must be greater than or equal to 2",
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Cluster_LeastRequestLbConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"wrapper",
":=",
"m",
".",
"GetChoiceCount",
"(",
")",
";",
"wrapper",
"!=",
"nil",
"{",
"if",
"wrapper",
".",
"GetValue",
"(",
")",
"<",
"2",
"{",
"return",
"Cluster_LeastRequestLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Cluster_LeastRequestLbConfig with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Cluster_LeastRequestLbConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L1015-L1032 |
146,991 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *Cluster_RingHashLbConfig) Validate() error {
if m == nil {
return nil
}
if wrapper := m.GetMinimumRingSize(); wrapper != nil {
if wrapper.GetValue() > 8388608 {
return Cluster_RingHashLbConfigValidationError{
field: "MinimumRingSize",
reason: "value must be less than or equal to 8388608",
}
}
}
if _, ok := Cluster_RingHashLbConfig_HashFunction_name[int32(m.GetHashFunction())]; !ok {
return Cluster_RingHashLbConfigValidationError{
field: "HashFunction",
reason: "value must be one of the defined enum values",
}
}
if wrapper := m.GetMaximumRingSize(); wrapper != nil {
if wrapper.GetValue() > 8388608 {
return Cluster_RingHashLbConfigValidationError{
field: "MaximumRingSize",
reason: "value must be less than or equal to 8388608",
}
}
}
return nil
} | go | func (m *Cluster_RingHashLbConfig) Validate() error {
if m == nil {
return nil
}
if wrapper := m.GetMinimumRingSize(); wrapper != nil {
if wrapper.GetValue() > 8388608 {
return Cluster_RingHashLbConfigValidationError{
field: "MinimumRingSize",
reason: "value must be less than or equal to 8388608",
}
}
}
if _, ok := Cluster_RingHashLbConfig_HashFunction_name[int32(m.GetHashFunction())]; !ok {
return Cluster_RingHashLbConfigValidationError{
field: "HashFunction",
reason: "value must be one of the defined enum values",
}
}
if wrapper := m.GetMaximumRingSize(); wrapper != nil {
if wrapper.GetValue() > 8388608 {
return Cluster_RingHashLbConfigValidationError{
field: "MaximumRingSize",
reason: "value must be less than or equal to 8388608",
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Cluster_RingHashLbConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"wrapper",
":=",
"m",
".",
"GetMinimumRingSize",
"(",
")",
";",
"wrapper",
"!=",
"nil",
"{",
"if",
"wrapper",
".",
"GetValue",
"(",
")",
">",
"8388608",
"{",
"return",
"Cluster_RingHashLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"Cluster_RingHashLbConfig_HashFunction_name",
"[",
"int32",
"(",
"m",
".",
"GetHashFunction",
"(",
")",
")",
"]",
";",
"!",
"ok",
"{",
"return",
"Cluster_RingHashLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"wrapper",
":=",
"m",
".",
"GetMaximumRingSize",
"(",
")",
";",
"wrapper",
"!=",
"nil",
"{",
"if",
"wrapper",
".",
"GetValue",
"(",
")",
">",
"8388608",
"{",
"return",
"Cluster_RingHashLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Cluster_RingHashLbConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Cluster_RingHashLbConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L1094-L1129 |
146,992 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *Cluster_CommonLbConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetHealthyPanicThreshold()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "HealthyPanicThreshold",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetUpdateMergeWindow()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "UpdateMergeWindow",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
switch m.LocalityConfigSpecifier.(type) {
case *Cluster_CommonLbConfig_ZoneAwareLbConfig_:
{
tmp := m.GetZoneAwareLbConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "ZoneAwareLbConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *Cluster_CommonLbConfig_LocalityWeightedLbConfig_:
{
tmp := m.GetLocalityWeightedLbConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "LocalityWeightedLbConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *Cluster_CommonLbConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetHealthyPanicThreshold()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "HealthyPanicThreshold",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetUpdateMergeWindow()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "UpdateMergeWindow",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
switch m.LocalityConfigSpecifier.(type) {
case *Cluster_CommonLbConfig_ZoneAwareLbConfig_:
{
tmp := m.GetZoneAwareLbConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "ZoneAwareLbConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *Cluster_CommonLbConfig_LocalityWeightedLbConfig_:
{
tmp := m.GetLocalityWeightedLbConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfigValidationError{
field: "LocalityWeightedLbConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Cluster_CommonLbConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetHealthyPanicThreshold",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_CommonLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetUpdateMergeWindow",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_CommonLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"switch",
"m",
".",
"LocalityConfigSpecifier",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Cluster_CommonLbConfig_ZoneAwareLbConfig_",
":",
"{",
"tmp",
":=",
"m",
".",
"GetZoneAwareLbConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_CommonLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"case",
"*",
"Cluster_CommonLbConfig_LocalityWeightedLbConfig_",
":",
"{",
"tmp",
":=",
"m",
".",
"GetLocalityWeightedLbConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_CommonLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Cluster_CommonLbConfig with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Cluster_CommonLbConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L1260-L1334 |
146,993 | envoyproxy/go-control-plane | envoy/api/v2/cds.pb.validate.go | Validate | func (m *Cluster_CommonLbConfig_ZoneAwareLbConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetRoutingEnabled()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfig_ZoneAwareLbConfigValidationError{
field: "RoutingEnabled",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetMinClusterSize()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfig_ZoneAwareLbConfigValidationError{
field: "MinClusterSize",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *Cluster_CommonLbConfig_ZoneAwareLbConfig) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetRoutingEnabled()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfig_ZoneAwareLbConfigValidationError{
field: "RoutingEnabled",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetMinClusterSize()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return Cluster_CommonLbConfig_ZoneAwareLbConfigValidationError{
field: "MinClusterSize",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Cluster_CommonLbConfig_ZoneAwareLbConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetRoutingEnabled",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_CommonLbConfig_ZoneAwareLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetMinClusterSize",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"Cluster_CommonLbConfig_ZoneAwareLbConfigValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on Cluster_CommonLbConfig_ZoneAwareLbConfig
// with the rules defined in the proto definition for this message. If any
// rules are violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"Cluster_CommonLbConfig_ZoneAwareLbConfig",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/cds.pb.validate.go#L1463-L1499 |
146,994 | envoyproxy/go-control-plane | envoy/api/v2/auth/cert.pb.validate.go | Validate | func (m *TlsParameters) Validate() error {
if m == nil {
return nil
}
if _, ok := TlsParameters_TlsProtocol_name[int32(m.GetTlsMinimumProtocolVersion())]; !ok {
return TlsParametersValidationError{
field: "TlsMinimumProtocolVersion",
reason: "value must be one of the defined enum values",
}
}
if _, ok := TlsParameters_TlsProtocol_name[int32(m.GetTlsMaximumProtocolVersion())]; !ok {
return TlsParametersValidationError{
field: "TlsMaximumProtocolVersion",
reason: "value must be one of the defined enum values",
}
}
return nil
} | go | func (m *TlsParameters) Validate() error {
if m == nil {
return nil
}
if _, ok := TlsParameters_TlsProtocol_name[int32(m.GetTlsMinimumProtocolVersion())]; !ok {
return TlsParametersValidationError{
field: "TlsMinimumProtocolVersion",
reason: "value must be one of the defined enum values",
}
}
if _, ok := TlsParameters_TlsProtocol_name[int32(m.GetTlsMaximumProtocolVersion())]; !ok {
return TlsParametersValidationError{
field: "TlsMaximumProtocolVersion",
reason: "value must be one of the defined enum values",
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"TlsParameters",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"TlsParameters_TlsProtocol_name",
"[",
"int32",
"(",
"m",
".",
"GetTlsMinimumProtocolVersion",
"(",
")",
")",
"]",
";",
"!",
"ok",
"{",
"return",
"TlsParametersValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"TlsParameters_TlsProtocol_name",
"[",
"int32",
"(",
"m",
".",
"GetTlsMaximumProtocolVersion",
"(",
")",
")",
"]",
";",
"!",
"ok",
"{",
"return",
"TlsParametersValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on TlsParameters with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"TlsParameters",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/auth/cert.pb.validate.go#L39-L59 |
146,995 | envoyproxy/go-control-plane | envoy/api/v2/auth/cert.pb.validate.go | Validate | func (m *TlsCertificate) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetCertificateChain()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "CertificateChain",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetPrivateKey()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "PrivateKey",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetPassword()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "Password",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetOcspStaple()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "OcspStaple",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetSignedCertificateTimestamp() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: fmt.Sprintf("SignedCertificateTimestamp[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *TlsCertificate) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetCertificateChain()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "CertificateChain",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetPrivateKey()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "PrivateKey",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetPassword()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "Password",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetOcspStaple()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: "OcspStaple",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetSignedCertificateTimestamp() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsCertificateValidationError{
field: fmt.Sprintf("SignedCertificateTimestamp[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"TlsCertificate",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetCertificateChain",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TlsCertificateValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetPrivateKey",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TlsCertificateValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetPassword",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TlsCertificateValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetOcspStaple",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TlsCertificateValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetSignedCertificateTimestamp",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TlsCertificateValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on TlsCertificate with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"TlsCertificate",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/auth/cert.pb.validate.go#L118-L204 |
146,996 | envoyproxy/go-control-plane | envoy/api/v2/auth/cert.pb.validate.go | Validate | func (m *TlsSessionTicketKeys) Validate() error {
if m == nil {
return nil
}
if len(m.GetKeys()) < 1 {
return TlsSessionTicketKeysValidationError{
field: "Keys",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetKeys() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsSessionTicketKeysValidationError{
field: fmt.Sprintf("Keys[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *TlsSessionTicketKeys) Validate() error {
if m == nil {
return nil
}
if len(m.GetKeys()) < 1 {
return TlsSessionTicketKeysValidationError{
field: "Keys",
reason: "value must contain at least 1 item(s)",
}
}
for idx, item := range m.GetKeys() {
_, _ = idx, item
{
tmp := item
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return TlsSessionTicketKeysValidationError{
field: fmt.Sprintf("Keys[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"TlsSessionTicketKeys",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetKeys",
"(",
")",
")",
"<",
"1",
"{",
"return",
"TlsSessionTicketKeysValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetKeys",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"{",
"tmp",
":=",
"item",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"TlsSessionTicketKeysValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on TlsSessionTicketKeys with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"TlsSessionTicketKeys",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/auth/cert.pb.validate.go#L263-L296 |
146,997 | envoyproxy/go-control-plane | envoy/api/v2/auth/cert.pb.validate.go | Validate | func (m *CertificateValidationContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetTrustedCa()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "TrustedCa",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetVerifyCertificateSpki() {
_, _ = idx, item
if len(item) != 44 {
return CertificateValidationContextValidationError{
field: fmt.Sprintf("VerifyCertificateSpki[%v]", idx),
reason: "value length must be 44 bytes",
}
}
}
for idx, item := range m.GetVerifyCertificateHash() {
_, _ = idx, item
if l := len(item); l < 64 || l > 95 {
return CertificateValidationContextValidationError{
field: fmt.Sprintf("VerifyCertificateHash[%v]", idx),
reason: "value length must be between 64 and 95 bytes, inclusive",
}
}
}
{
tmp := m.GetRequireOcspStaple()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "RequireOcspStaple",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequireSignedCertificateTimestamp()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "RequireSignedCertificateTimestamp",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetCrl()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "Crl",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for AllowExpiredCertificate
return nil
} | go | func (m *CertificateValidationContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetTrustedCa()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "TrustedCa",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
for idx, item := range m.GetVerifyCertificateSpki() {
_, _ = idx, item
if len(item) != 44 {
return CertificateValidationContextValidationError{
field: fmt.Sprintf("VerifyCertificateSpki[%v]", idx),
reason: "value length must be 44 bytes",
}
}
}
for idx, item := range m.GetVerifyCertificateHash() {
_, _ = idx, item
if l := len(item); l < 64 || l > 95 {
return CertificateValidationContextValidationError{
field: fmt.Sprintf("VerifyCertificateHash[%v]", idx),
reason: "value length must be between 64 and 95 bytes, inclusive",
}
}
}
{
tmp := m.GetRequireOcspStaple()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "RequireOcspStaple",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequireSignedCertificateTimestamp()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "RequireSignedCertificateTimestamp",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetCrl()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CertificateValidationContextValidationError{
field: "Crl",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
// no validation rules for AllowExpiredCertificate
return nil
} | [
"func",
"(",
"m",
"*",
"CertificateValidationContext",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetTrustedCa",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CertificateValidationContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetVerifyCertificateSpki",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"if",
"len",
"(",
"item",
")",
"!=",
"44",
"{",
"return",
"CertificateValidationContextValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"for",
"idx",
",",
"item",
":=",
"range",
"m",
".",
"GetVerifyCertificateHash",
"(",
")",
"{",
"_",
",",
"_",
"=",
"idx",
",",
"item",
"\n\n",
"if",
"l",
":=",
"len",
"(",
"item",
")",
";",
"l",
"<",
"64",
"||",
"l",
">",
"95",
"{",
"return",
"CertificateValidationContextValidationError",
"{",
"field",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx",
")",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetRequireOcspStaple",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CertificateValidationContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetRequireSignedCertificateTimestamp",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CertificateValidationContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetCrl",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"CertificateValidationContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for AllowExpiredCertificate",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on CertificateValidationContext with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"CertificateValidationContext",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/auth/cert.pb.validate.go#L357-L449 |
146,998 | envoyproxy/go-control-plane | envoy/api/v2/auth/cert.pb.validate.go | Validate | func (m *UpstreamTlsContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetCommonTlsContext()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamTlsContextValidationError{
field: "CommonTlsContext",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(m.GetSni()) > 255 {
return UpstreamTlsContextValidationError{
field: "Sni",
reason: "value length must be at most 255 bytes",
}
}
// no validation rules for AllowRenegotiation
{
tmp := m.GetMaxSessionKeys()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamTlsContextValidationError{
field: "MaxSessionKeys",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | go | func (m *UpstreamTlsContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetCommonTlsContext()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamTlsContextValidationError{
field: "CommonTlsContext",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(m.GetSni()) > 255 {
return UpstreamTlsContextValidationError{
field: "Sni",
reason: "value length must be at most 255 bytes",
}
}
// no validation rules for AllowRenegotiation
{
tmp := m.GetMaxSessionKeys()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return UpstreamTlsContextValidationError{
field: "MaxSessionKeys",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"UpstreamTlsContext",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetCommonTlsContext",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"UpstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"m",
".",
"GetSni",
"(",
")",
")",
">",
"255",
"{",
"return",
"UpstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n\n",
"// no validation rules for AllowRenegotiation",
"{",
"tmp",
":=",
"m",
".",
"GetMaxSessionKeys",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"UpstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on UpstreamTlsContext with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"UpstreamTlsContext",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/auth/cert.pb.validate.go#L693-L738 |
146,999 | envoyproxy/go-control-plane | envoy/api/v2/auth/cert.pb.validate.go | Validate | func (m *DownstreamTlsContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetCommonTlsContext()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "CommonTlsContext",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequireClientCertificate()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "RequireClientCertificate",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequireSni()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "RequireSni",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
switch m.SessionTicketKeysType.(type) {
case *DownstreamTlsContext_SessionTicketKeys:
{
tmp := m.GetSessionTicketKeys()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "SessionTicketKeys",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *DownstreamTlsContext_SessionTicketKeysSdsSecretConfig:
{
tmp := m.GetSessionTicketKeysSdsSecretConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "SessionTicketKeysSdsSecretConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | go | func (m *DownstreamTlsContext) Validate() error {
if m == nil {
return nil
}
{
tmp := m.GetCommonTlsContext()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "CommonTlsContext",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequireClientCertificate()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "RequireClientCertificate",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
{
tmp := m.GetRequireSni()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "RequireSni",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
switch m.SessionTicketKeysType.(type) {
case *DownstreamTlsContext_SessionTicketKeys:
{
tmp := m.GetSessionTicketKeys()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "SessionTicketKeys",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
case *DownstreamTlsContext_SessionTicketKeysSdsSecretConfig:
{
tmp := m.GetSessionTicketKeysSdsSecretConfig()
if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return DownstreamTlsContextValidationError{
field: "SessionTicketKeysSdsSecretConfig",
reason: "embedded message failed validation",
cause: err,
}
}
}
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"DownstreamTlsContext",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetCommonTlsContext",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"DownstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetRequireClientCertificate",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"DownstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"{",
"tmp",
":=",
"m",
".",
"GetRequireSni",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"DownstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"switch",
"m",
".",
"SessionTicketKeysType",
".",
"(",
"type",
")",
"{",
"case",
"*",
"DownstreamTlsContext_SessionTicketKeys",
":",
"{",
"tmp",
":=",
"m",
".",
"GetSessionTicketKeys",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"DownstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"case",
"*",
"DownstreamTlsContext_SessionTicketKeysSdsSecretConfig",
":",
"{",
"tmp",
":=",
"m",
".",
"GetSessionTicketKeysSdsSecretConfig",
"(",
")",
"\n\n",
"if",
"v",
",",
"ok",
":=",
"interface",
"{",
"}",
"(",
"tmp",
")",
".",
"(",
"interface",
"{",
"Validate",
"(",
")",
"error",
"}",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"v",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"DownstreamTlsContextValidationError",
"{",
"field",
":",
"\"",
"\"",
",",
"reason",
":",
"\"",
"\"",
",",
"cause",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
| // Validate checks the field values on DownstreamTlsContext with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned. | [
"Validate",
"checks",
"the",
"field",
"values",
"on",
"DownstreamTlsContext",
"with",
"the",
"rules",
"defined",
"in",
"the",
"proto",
"definition",
"for",
"this",
"message",
".",
"If",
"any",
"rules",
"are",
"violated",
"an",
"error",
"is",
"returned",
"."
]
| 9ffbaf293221f9fef735838632a9109d00aa2f4c | https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/auth/cert.pb.validate.go#L799-L888 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.