repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
stellar/go-stellar-base | xdr/xdr_generated.go | MustIpv6 | func (u PeerAddressIp) MustIpv6() [16]byte {
val, ok := u.GetIpv6()
if !ok {
panic("arm Ipv6 is not set")
}
return val
} | go | func (u PeerAddressIp) MustIpv6() [16]byte {
val, ok := u.GetIpv6()
if !ok {
panic("arm Ipv6 is not set")
}
return val
} | [
"func",
"(",
"u",
"PeerAddressIp",
")",
"MustIpv6",
"(",
")",
"[",
"16",
"]",
"byte",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetIpv6",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Ipv6 is not set\"",
")",
"\n",
"}",
"\n",
"return",
... | // MustIpv6 retrieves the Ipv6 value from the union,
// panicing if the value is not set. | [
"MustIpv6",
"retrieves",
"the",
"Ipv6",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6154-L6162 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetIpv6 | func (u PeerAddressIp) GetIpv6() (result [16]byte, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Ipv6" {
result = *u.Ipv6
ok = true
}
return
} | go | func (u PeerAddressIp) GetIpv6() (result [16]byte, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Ipv6" {
result = *u.Ipv6
ok = true
}
return
} | [
"func",
"(",
"u",
"PeerAddressIp",
")",
"GetIpv6",
"(",
")",
"(",
"result",
"[",
"16",
"]",
"byte",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"ar... | // GetIpv6 retrieves the Ipv6 value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetIpv6",
"retrieves",
"the",
"Ipv6",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6166-L6175 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | ValidEnum | func (e MessageType) ValidEnum(v int32) bool {
_, ok := messageTypeMap[v]
return ok
} | go | func (e MessageType) ValidEnum(v int32) bool {
_, ok := messageTypeMap[v]
return ok
} | [
"func",
"(",
"e",
"MessageType",
")",
"ValidEnum",
"(",
"v",
"int32",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"messageTypeMap",
"[",
"v",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for MessageType | [
"ValidEnum",
"validates",
"a",
"proposed",
"value",
"for",
"this",
"enum",
".",
"Implements",
"the",
"Enum",
"interface",
"for",
"MessageType"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6261-L6264 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | ArmForSwitch | func (u StellarMessage) ArmForSwitch(sw int32) (string, bool) {
switch MessageType(sw) {
case MessageTypeErrorMsg:
return "Error", true
case MessageTypeHello:
return "Hello", true
case MessageTypeAuth:
return "Auth", true
case MessageTypeDontHave:
return "DontHave", true
case MessageTypeGetPeers:
return... | go | func (u StellarMessage) ArmForSwitch(sw int32) (string, bool) {
switch MessageType(sw) {
case MessageTypeErrorMsg:
return "Error", true
case MessageTypeHello:
return "Hello", true
case MessageTypeAuth:
return "Auth", true
case MessageTypeDontHave:
return "DontHave", true
case MessageTypeGetPeers:
return... | [
"func",
"(",
"u",
"StellarMessage",
")",
"ArmForSwitch",
"(",
"sw",
"int32",
")",
"(",
"string",
",",
"bool",
")",
"{",
"switch",
"MessageType",
"(",
"sw",
")",
"{",
"case",
"MessageTypeErrorMsg",
":",
"return",
"\"Error\"",
",",
"true",
"\n",
"case",
"M... | // ArmForSwitch returns which field name should be used for storing
// the value for an instance of StellarMessage | [
"ArmForSwitch",
"returns",
"which",
"field",
"name",
"should",
"be",
"used",
"for",
"storing",
"the",
"value",
"for",
"an",
"instance",
"of",
"StellarMessage"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6345-L6375 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | NewStellarMessage | func NewStellarMessage(aType MessageType, value interface{}) (result StellarMessage, err error) {
result.Type = aType
switch MessageType(aType) {
case MessageTypeErrorMsg:
tv, ok := value.(Error)
if !ok {
err = fmt.Errorf("invalid value, must be Error")
return
}
result.Error = &tv
case MessageTypeHell... | go | func NewStellarMessage(aType MessageType, value interface{}) (result StellarMessage, err error) {
result.Type = aType
switch MessageType(aType) {
case MessageTypeErrorMsg:
tv, ok := value.(Error)
if !ok {
err = fmt.Errorf("invalid value, must be Error")
return
}
result.Error = &tv
case MessageTypeHell... | [
"func",
"NewStellarMessage",
"(",
"aType",
"MessageType",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"result",
"StellarMessage",
",",
"err",
"error",
")",
"{",
"result",
".",
"Type",
"=",
"aType",
"\n",
"switch",
"MessageType",
"(",
"aType",
")",
"{",
... | // NewStellarMessage creates a new StellarMessage. | [
"NewStellarMessage",
"creates",
"a",
"new",
"StellarMessage",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6378-L6469 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustError | func (u StellarMessage) MustError() Error {
val, ok := u.GetError()
if !ok {
panic("arm Error is not set")
}
return val
} | go | func (u StellarMessage) MustError() Error {
val, ok := u.GetError()
if !ok {
panic("arm Error is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustError",
"(",
")",
"Error",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetError",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Error is not set\"",
")",
"\n",
"}",
"\n",
"return",
"val",
"\n",
... | // MustError retrieves the Error value from the union,
// panicing if the value is not set. | [
"MustError",
"retrieves",
"the",
"Error",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6473-L6481 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetError | func (u StellarMessage) GetError() (result Error, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Error" {
result = *u.Error
ok = true
}
return
} | go | func (u StellarMessage) GetError() (result Error, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Error" {
result = *u.Error
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetError",
"(",
")",
"(",
"result",
"Error",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
"==",
"... | // GetError retrieves the Error value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetError",
"retrieves",
"the",
"Error",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6485-L6494 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustHello | func (u StellarMessage) MustHello() Hello {
val, ok := u.GetHello()
if !ok {
panic("arm Hello is not set")
}
return val
} | go | func (u StellarMessage) MustHello() Hello {
val, ok := u.GetHello()
if !ok {
panic("arm Hello is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustHello",
"(",
")",
"Hello",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetHello",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Hello is not set\"",
")",
"\n",
"}",
"\n",
"return",
"val",
"\n",
... | // MustHello retrieves the Hello value from the union,
// panicing if the value is not set. | [
"MustHello",
"retrieves",
"the",
"Hello",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6498-L6506 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetHello | func (u StellarMessage) GetHello() (result Hello, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Hello" {
result = *u.Hello
ok = true
}
return
} | go | func (u StellarMessage) GetHello() (result Hello, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Hello" {
result = *u.Hello
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetHello",
"(",
")",
"(",
"result",
"Hello",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
"==",
"... | // GetHello retrieves the Hello value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetHello",
"retrieves",
"the",
"Hello",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6510-L6519 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustAuth | func (u StellarMessage) MustAuth() Auth {
val, ok := u.GetAuth()
if !ok {
panic("arm Auth is not set")
}
return val
} | go | func (u StellarMessage) MustAuth() Auth {
val, ok := u.GetAuth()
if !ok {
panic("arm Auth is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustAuth",
"(",
")",
"Auth",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetAuth",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Auth is not set\"",
")",
"\n",
"}",
"\n",
"return",
"val",
"\n",
"}"... | // MustAuth retrieves the Auth value from the union,
// panicing if the value is not set. | [
"MustAuth",
"retrieves",
"the",
"Auth",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6523-L6531 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetAuth | func (u StellarMessage) GetAuth() (result Auth, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Auth" {
result = *u.Auth
ok = true
}
return
} | go | func (u StellarMessage) GetAuth() (result Auth, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Auth" {
result = *u.Auth
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetAuth",
"(",
")",
"(",
"result",
"Auth",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
"==",
"\"... | // GetAuth retrieves the Auth value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetAuth",
"retrieves",
"the",
"Auth",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6535-L6544 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustDontHave | func (u StellarMessage) MustDontHave() DontHave {
val, ok := u.GetDontHave()
if !ok {
panic("arm DontHave is not set")
}
return val
} | go | func (u StellarMessage) MustDontHave() DontHave {
val, ok := u.GetDontHave()
if !ok {
panic("arm DontHave is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustDontHave",
"(",
")",
"DontHave",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetDontHave",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm DontHave is not set\"",
")",
"\n",
"}",
"\n",
"return",
"val... | // MustDontHave retrieves the DontHave value from the union,
// panicing if the value is not set. | [
"MustDontHave",
"retrieves",
"the",
"DontHave",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6548-L6556 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetDontHave | func (u StellarMessage) GetDontHave() (result DontHave, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "DontHave" {
result = *u.DontHave
ok = true
}
return
} | go | func (u StellarMessage) GetDontHave() (result DontHave, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "DontHave" {
result = *u.DontHave
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetDontHave",
"(",
")",
"(",
"result",
"DontHave",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
"==... | // GetDontHave retrieves the DontHave value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetDontHave",
"retrieves",
"the",
"DontHave",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6560-L6569 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustPeers | func (u StellarMessage) MustPeers() []PeerAddress {
val, ok := u.GetPeers()
if !ok {
panic("arm Peers is not set")
}
return val
} | go | func (u StellarMessage) MustPeers() []PeerAddress {
val, ok := u.GetPeers()
if !ok {
panic("arm Peers is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustPeers",
"(",
")",
"[",
"]",
"PeerAddress",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetPeers",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Peers is not set\"",
")",
"\n",
"}",
"\n",
"return"... | // MustPeers retrieves the Peers value from the union,
// panicing if the value is not set. | [
"MustPeers",
"retrieves",
"the",
"Peers",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6573-L6581 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetPeers | func (u StellarMessage) GetPeers() (result []PeerAddress, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Peers" {
result = *u.Peers
ok = true
}
return
} | go | func (u StellarMessage) GetPeers() (result []PeerAddress, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Peers" {
result = *u.Peers
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetPeers",
"(",
")",
"(",
"result",
"[",
"]",
"PeerAddress",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"a... | // GetPeers retrieves the Peers value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetPeers",
"retrieves",
"the",
"Peers",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6585-L6594 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustTxSetHash | func (u StellarMessage) MustTxSetHash() Uint256 {
val, ok := u.GetTxSetHash()
if !ok {
panic("arm TxSetHash is not set")
}
return val
} | go | func (u StellarMessage) MustTxSetHash() Uint256 {
val, ok := u.GetTxSetHash()
if !ok {
panic("arm TxSetHash is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustTxSetHash",
"(",
")",
"Uint256",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetTxSetHash",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm TxSetHash is not set\"",
")",
"\n",
"}",
"\n",
"return",
"v... | // MustTxSetHash retrieves the TxSetHash value from the union,
// panicing if the value is not set. | [
"MustTxSetHash",
"retrieves",
"the",
"TxSetHash",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6598-L6606 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetTxSetHash | func (u StellarMessage) GetTxSetHash() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "TxSetHash" {
result = *u.TxSetHash
ok = true
}
return
} | go | func (u StellarMessage) GetTxSetHash() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "TxSetHash" {
result = *u.TxSetHash
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetTxSetHash",
"(",
")",
"(",
"result",
"Uint256",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
"==... | // GetTxSetHash retrieves the TxSetHash value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetTxSetHash",
"retrieves",
"the",
"TxSetHash",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6610-L6619 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustTxSet | func (u StellarMessage) MustTxSet() TransactionSet {
val, ok := u.GetTxSet()
if !ok {
panic("arm TxSet is not set")
}
return val
} | go | func (u StellarMessage) MustTxSet() TransactionSet {
val, ok := u.GetTxSet()
if !ok {
panic("arm TxSet is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustTxSet",
"(",
")",
"TransactionSet",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetTxSet",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm TxSet is not set\"",
")",
"\n",
"}",
"\n",
"return",
"val",
... | // MustTxSet retrieves the TxSet value from the union,
// panicing if the value is not set. | [
"MustTxSet",
"retrieves",
"the",
"TxSet",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6623-L6631 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetTxSet | func (u StellarMessage) GetTxSet() (result TransactionSet, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "TxSet" {
result = *u.TxSet
ok = true
}
return
} | go | func (u StellarMessage) GetTxSet() (result TransactionSet, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "TxSet" {
result = *u.TxSet
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetTxSet",
"(",
")",
"(",
"result",
"TransactionSet",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
... | // GetTxSet retrieves the TxSet value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetTxSet",
"retrieves",
"the",
"TxSet",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6635-L6644 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustTransaction | func (u StellarMessage) MustTransaction() TransactionEnvelope {
val, ok := u.GetTransaction()
if !ok {
panic("arm Transaction is not set")
}
return val
} | go | func (u StellarMessage) MustTransaction() TransactionEnvelope {
val, ok := u.GetTransaction()
if !ok {
panic("arm Transaction is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustTransaction",
"(",
")",
"TransactionEnvelope",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetTransaction",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Transaction is not set\"",
")",
"\n",
"}",
"\n"... | // MustTransaction retrieves the Transaction value from the union,
// panicing if the value is not set. | [
"MustTransaction",
"retrieves",
"the",
"Transaction",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6648-L6656 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetTransaction | func (u StellarMessage) GetTransaction() (result TransactionEnvelope, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Transaction" {
result = *u.Transaction
ok = true
}
return
} | go | func (u StellarMessage) GetTransaction() (result TransactionEnvelope, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Transaction" {
result = *u.Transaction
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetTransaction",
"(",
")",
"(",
"result",
"TransactionEnvelope",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"a... | // GetTransaction retrieves the Transaction value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetTransaction",
"retrieves",
"the",
"Transaction",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6660-L6669 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustQSetHash | func (u StellarMessage) MustQSetHash() Uint256 {
val, ok := u.GetQSetHash()
if !ok {
panic("arm QSetHash is not set")
}
return val
} | go | func (u StellarMessage) MustQSetHash() Uint256 {
val, ok := u.GetQSetHash()
if !ok {
panic("arm QSetHash is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustQSetHash",
"(",
")",
"Uint256",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetQSetHash",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm QSetHash is not set\"",
")",
"\n",
"}",
"\n",
"return",
"val"... | // MustQSetHash retrieves the QSetHash value from the union,
// panicing if the value is not set. | [
"MustQSetHash",
"retrieves",
"the",
"QSetHash",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6673-L6681 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetQSetHash | func (u StellarMessage) GetQSetHash() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "QSetHash" {
result = *u.QSetHash
ok = true
}
return
} | go | func (u StellarMessage) GetQSetHash() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "QSetHash" {
result = *u.QSetHash
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetQSetHash",
"(",
")",
"(",
"result",
"Uint256",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
"=="... | // GetQSetHash retrieves the QSetHash value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetQSetHash",
"retrieves",
"the",
"QSetHash",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6685-L6694 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustQSet | func (u StellarMessage) MustQSet() ScpQuorumSet {
val, ok := u.GetQSet()
if !ok {
panic("arm QSet is not set")
}
return val
} | go | func (u StellarMessage) MustQSet() ScpQuorumSet {
val, ok := u.GetQSet()
if !ok {
panic("arm QSet is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustQSet",
"(",
")",
"ScpQuorumSet",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetQSet",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm QSet is not set\"",
")",
"\n",
"}",
"\n",
"return",
"val",
"\n... | // MustQSet retrieves the QSet value from the union,
// panicing if the value is not set. | [
"MustQSet",
"retrieves",
"the",
"QSet",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6698-L6706 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetQSet | func (u StellarMessage) GetQSet() (result ScpQuorumSet, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "QSet" {
result = *u.QSet
ok = true
}
return
} | go | func (u StellarMessage) GetQSet() (result ScpQuorumSet, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "QSet" {
result = *u.QSet
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetQSet",
"(",
")",
"(",
"result",
"ScpQuorumSet",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
"==... | // GetQSet retrieves the QSet value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetQSet",
"retrieves",
"the",
"QSet",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6710-L6719 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustEnvelope | func (u StellarMessage) MustEnvelope() ScpEnvelope {
val, ok := u.GetEnvelope()
if !ok {
panic("arm Envelope is not set")
}
return val
} | go | func (u StellarMessage) MustEnvelope() ScpEnvelope {
val, ok := u.GetEnvelope()
if !ok {
panic("arm Envelope is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustEnvelope",
"(",
")",
"ScpEnvelope",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetEnvelope",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Envelope is not set\"",
")",
"\n",
"}",
"\n",
"return",
"... | // MustEnvelope retrieves the Envelope value from the union,
// panicing if the value is not set. | [
"MustEnvelope",
"retrieves",
"the",
"Envelope",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6723-L6731 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetEnvelope | func (u StellarMessage) GetEnvelope() (result ScpEnvelope, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Envelope" {
result = *u.Envelope
ok = true
}
return
} | go | func (u StellarMessage) GetEnvelope() (result ScpEnvelope, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Envelope" {
result = *u.Envelope
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetEnvelope",
"(",
")",
"(",
"result",
"ScpEnvelope",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
... | // GetEnvelope retrieves the Envelope value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetEnvelope",
"retrieves",
"the",
"Envelope",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6735-L6744 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustGetScpLedgerSeq | func (u StellarMessage) MustGetScpLedgerSeq() Uint32 {
val, ok := u.GetGetScpLedgerSeq()
if !ok {
panic("arm GetScpLedgerSeq is not set")
}
return val
} | go | func (u StellarMessage) MustGetScpLedgerSeq() Uint32 {
val, ok := u.GetGetScpLedgerSeq()
if !ok {
panic("arm GetScpLedgerSeq is not set")
}
return val
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustGetScpLedgerSeq",
"(",
")",
"Uint32",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetGetScpLedgerSeq",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm GetScpLedgerSeq is not set\"",
")",
"\n",
"}",
"\n",... | // MustGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union,
// panicing if the value is not set. | [
"MustGetScpLedgerSeq",
"retrieves",
"the",
"GetScpLedgerSeq",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6748-L6756 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetGetScpLedgerSeq | func (u StellarMessage) GetGetScpLedgerSeq() (result Uint32, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "GetScpLedgerSeq" {
result = *u.GetScpLedgerSeq
ok = true
}
return
} | go | func (u StellarMessage) GetGetScpLedgerSeq() (result Uint32, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "GetScpLedgerSeq" {
result = *u.GetScpLedgerSeq
ok = true
}
return
} | [
"func",
"(",
"u",
"StellarMessage",
")",
"GetGetScpLedgerSeq",
"(",
")",
"(",
"result",
"Uint32",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armName",
... | // GetGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetGetScpLedgerSeq",
"retrieves",
"the",
"GetScpLedgerSeq",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6760-L6769 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | ArmForSwitch | func (u AuthenticatedMessage) ArmForSwitch(sw int32) (string, bool) {
switch Uint32(sw) {
case 0:
return "V0", true
}
return "-", false
} | go | func (u AuthenticatedMessage) ArmForSwitch(sw int32) (string, bool) {
switch Uint32(sw) {
case 0:
return "V0", true
}
return "-", false
} | [
"func",
"(",
"u",
"AuthenticatedMessage",
")",
"ArmForSwitch",
"(",
"sw",
"int32",
")",
"(",
"string",
",",
"bool",
")",
"{",
"switch",
"Uint32",
"(",
"sw",
")",
"{",
"case",
"0",
":",
"return",
"\"V0\"",
",",
"true",
"\n",
"}",
"\n",
"return",
"\"-\... | // ArmForSwitch returns which field name should be used for storing
// the value for an instance of AuthenticatedMessage | [
"ArmForSwitch",
"returns",
"which",
"field",
"name",
"should",
"be",
"used",
"for",
"storing",
"the",
"value",
"for",
"an",
"instance",
"of",
"AuthenticatedMessage"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6812-L6818 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | NewAuthenticatedMessage | func NewAuthenticatedMessage(v Uint32, value interface{}) (result AuthenticatedMessage, err error) {
result.V = v
switch Uint32(v) {
case 0:
tv, ok := value.(AuthenticatedMessageV0)
if !ok {
err = fmt.Errorf("invalid value, must be AuthenticatedMessageV0")
return
}
result.V0 = &tv
}
return
} | go | func NewAuthenticatedMessage(v Uint32, value interface{}) (result AuthenticatedMessage, err error) {
result.V = v
switch Uint32(v) {
case 0:
tv, ok := value.(AuthenticatedMessageV0)
if !ok {
err = fmt.Errorf("invalid value, must be AuthenticatedMessageV0")
return
}
result.V0 = &tv
}
return
} | [
"func",
"NewAuthenticatedMessage",
"(",
"v",
"Uint32",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"result",
"AuthenticatedMessage",
",",
"err",
"error",
")",
"{",
"result",
".",
"V",
"=",
"v",
"\n",
"switch",
"Uint32",
"(",
"v",
")",
"{",
"case",
"... | // NewAuthenticatedMessage creates a new AuthenticatedMessage. | [
"NewAuthenticatedMessage",
"creates",
"a",
"new",
"AuthenticatedMessage",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6821-L6833 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | ValidEnum | func (e ScpStatementType) ValidEnum(v int32) bool {
_, ok := scpStatementTypeMap[v]
return ok
} | go | func (e ScpStatementType) ValidEnum(v int32) bool {
_, ok := scpStatementTypeMap[v]
return ok
} | [
"func",
"(",
"e",
"ScpStatementType",
")",
"ValidEnum",
"(",
"v",
"int32",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"scpStatementTypeMap",
"[",
"v",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for ScpStatementType | [
"ValidEnum",
"validates",
"a",
"proposed",
"value",
"for",
"this",
"enum",
".",
"Implements",
"the",
"Enum",
"interface",
"for",
"ScpStatementType"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6907-L6910 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | ArmForSwitch | func (u ScpStatementPledges) ArmForSwitch(sw int32) (string, bool) {
switch ScpStatementType(sw) {
case ScpStatementTypeScpStPrepare:
return "Prepare", true
case ScpStatementTypeScpStConfirm:
return "Confirm", true
case ScpStatementTypeScpStExternalize:
return "Externalize", true
case ScpStatementTypeScpStNo... | go | func (u ScpStatementPledges) ArmForSwitch(sw int32) (string, bool) {
switch ScpStatementType(sw) {
case ScpStatementTypeScpStPrepare:
return "Prepare", true
case ScpStatementTypeScpStConfirm:
return "Confirm", true
case ScpStatementTypeScpStExternalize:
return "Externalize", true
case ScpStatementTypeScpStNo... | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"ArmForSwitch",
"(",
"sw",
"int32",
")",
"(",
"string",
",",
"bool",
")",
"{",
"switch",
"ScpStatementType",
"(",
"sw",
")",
"{",
"case",
"ScpStatementTypeScpStPrepare",
":",
"return",
"\"Prepare\"",
",",
"true",
... | // ArmForSwitch returns which field name should be used for storing
// the value for an instance of ScpStatementPledges | [
"ArmForSwitch",
"returns",
"which",
"field",
"name",
"should",
"be",
"used",
"for",
"storing",
"the",
"value",
"for",
"an",
"instance",
"of",
"ScpStatementPledges"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7038-L7050 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | NewScpStatementPledges | func NewScpStatementPledges(aType ScpStatementType, value interface{}) (result ScpStatementPledges, err error) {
result.Type = aType
switch ScpStatementType(aType) {
case ScpStatementTypeScpStPrepare:
tv, ok := value.(ScpStatementPrepare)
if !ok {
err = fmt.Errorf("invalid value, must be ScpStatementPrepare")... | go | func NewScpStatementPledges(aType ScpStatementType, value interface{}) (result ScpStatementPledges, err error) {
result.Type = aType
switch ScpStatementType(aType) {
case ScpStatementTypeScpStPrepare:
tv, ok := value.(ScpStatementPrepare)
if !ok {
err = fmt.Errorf("invalid value, must be ScpStatementPrepare")... | [
"func",
"NewScpStatementPledges",
"(",
"aType",
"ScpStatementType",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"result",
"ScpStatementPledges",
",",
"err",
"error",
")",
"{",
"result",
".",
"Type",
"=",
"aType",
"\n",
"switch",
"ScpStatementType",
"(",
"aT... | // NewScpStatementPledges creates a new ScpStatementPledges. | [
"NewScpStatementPledges",
"creates",
"a",
"new",
"ScpStatementPledges",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7053-L7086 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustPrepare | func (u ScpStatementPledges) MustPrepare() ScpStatementPrepare {
val, ok := u.GetPrepare()
if !ok {
panic("arm Prepare is not set")
}
return val
} | go | func (u ScpStatementPledges) MustPrepare() ScpStatementPrepare {
val, ok := u.GetPrepare()
if !ok {
panic("arm Prepare is not set")
}
return val
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"MustPrepare",
"(",
")",
"ScpStatementPrepare",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetPrepare",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Prepare is not set\"",
")",
"\n",
"}",
"\n",
"re... | // MustPrepare retrieves the Prepare value from the union,
// panicing if the value is not set. | [
"MustPrepare",
"retrieves",
"the",
"Prepare",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7090-L7098 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetPrepare | func (u ScpStatementPledges) GetPrepare() (result ScpStatementPrepare, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Prepare" {
result = *u.Prepare
ok = true
}
return
} | go | func (u ScpStatementPledges) GetPrepare() (result ScpStatementPrepare, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Prepare" {
result = *u.Prepare
ok = true
}
return
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"GetPrepare",
"(",
")",
"(",
"result",
"ScpStatementPrepare",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"... | // GetPrepare retrieves the Prepare value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetPrepare",
"retrieves",
"the",
"Prepare",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7102-L7111 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustConfirm | func (u ScpStatementPledges) MustConfirm() ScpStatementConfirm {
val, ok := u.GetConfirm()
if !ok {
panic("arm Confirm is not set")
}
return val
} | go | func (u ScpStatementPledges) MustConfirm() ScpStatementConfirm {
val, ok := u.GetConfirm()
if !ok {
panic("arm Confirm is not set")
}
return val
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"MustConfirm",
"(",
")",
"ScpStatementConfirm",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetConfirm",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Confirm is not set\"",
")",
"\n",
"}",
"\n",
"re... | // MustConfirm retrieves the Confirm value from the union,
// panicing if the value is not set. | [
"MustConfirm",
"retrieves",
"the",
"Confirm",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7115-L7123 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetConfirm | func (u ScpStatementPledges) GetConfirm() (result ScpStatementConfirm, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Confirm" {
result = *u.Confirm
ok = true
}
return
} | go | func (u ScpStatementPledges) GetConfirm() (result ScpStatementConfirm, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Confirm" {
result = *u.Confirm
ok = true
}
return
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"GetConfirm",
"(",
")",
"(",
"result",
"ScpStatementConfirm",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"... | // GetConfirm retrieves the Confirm value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetConfirm",
"retrieves",
"the",
"Confirm",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7127-L7136 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustExternalize | func (u ScpStatementPledges) MustExternalize() ScpStatementExternalize {
val, ok := u.GetExternalize()
if !ok {
panic("arm Externalize is not set")
}
return val
} | go | func (u ScpStatementPledges) MustExternalize() ScpStatementExternalize {
val, ok := u.GetExternalize()
if !ok {
panic("arm Externalize is not set")
}
return val
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"MustExternalize",
"(",
")",
"ScpStatementExternalize",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetExternalize",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Externalize is not set\"",
")",
"\n",
"}... | // MustExternalize retrieves the Externalize value from the union,
// panicing if the value is not set. | [
"MustExternalize",
"retrieves",
"the",
"Externalize",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7140-L7148 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetExternalize | func (u ScpStatementPledges) GetExternalize() (result ScpStatementExternalize, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Externalize" {
result = *u.Externalize
ok = true
}
return
} | go | func (u ScpStatementPledges) GetExternalize() (result ScpStatementExternalize, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Externalize" {
result = *u.Externalize
ok = true
}
return
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"GetExternalize",
"(",
")",
"(",
"result",
"ScpStatementExternalize",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"... | // GetExternalize retrieves the Externalize value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetExternalize",
"retrieves",
"the",
"Externalize",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7152-L7161 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | MustNominate | func (u ScpStatementPledges) MustNominate() ScpNomination {
val, ok := u.GetNominate()
if !ok {
panic("arm Nominate is not set")
}
return val
} | go | func (u ScpStatementPledges) MustNominate() ScpNomination {
val, ok := u.GetNominate()
if !ok {
panic("arm Nominate is not set")
}
return val
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"MustNominate",
"(",
")",
"ScpNomination",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetNominate",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"arm Nominate is not set\"",
")",
"\n",
"}",
"\n",
"retur... | // MustNominate retrieves the Nominate value from the union,
// panicing if the value is not set. | [
"MustNominate",
"retrieves",
"the",
"Nominate",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7165-L7173 | test |
stellar/go-stellar-base | xdr/xdr_generated.go | GetNominate | func (u ScpStatementPledges) GetNominate() (result ScpNomination, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Nominate" {
result = *u.Nominate
ok = true
}
return
} | go | func (u ScpStatementPledges) GetNominate() (result ScpNomination, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Nominate" {
result = *u.Nominate
ok = true
}
return
} | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"GetNominate",
"(",
")",
"(",
"result",
"ScpNomination",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n",
"if",
"armNa... | // GetNominate retrieves the Nominate value from the union,
// returning ok if the union's switch indicated the value is valid. | [
"GetNominate",
"retrieves",
"the",
"Nominate",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7177-L7186 | test |
stellar/go-stellar-base | xdr/main.go | SafeUnmarshalBase64 | func SafeUnmarshalBase64(data string, dest interface{}) error {
count := &countWriter{}
l := len(data)
b64 := io.TeeReader(strings.NewReader(data), count)
raw := base64.NewDecoder(base64.StdEncoding, b64)
_, err := Unmarshal(raw, dest)
if err != nil {
return err
}
if count.Count != l {
return fmt.Errorf(... | go | func SafeUnmarshalBase64(data string, dest interface{}) error {
count := &countWriter{}
l := len(data)
b64 := io.TeeReader(strings.NewReader(data), count)
raw := base64.NewDecoder(base64.StdEncoding, b64)
_, err := Unmarshal(raw, dest)
if err != nil {
return err
}
if count.Count != l {
return fmt.Errorf(... | [
"func",
"SafeUnmarshalBase64",
"(",
"data",
"string",
",",
"dest",
"interface",
"{",
"}",
")",
"error",
"{",
"count",
":=",
"&",
"countWriter",
"{",
"}",
"\n",
"l",
":=",
"len",
"(",
"data",
")",
"\n",
"b64",
":=",
"io",
".",
"TeeReader",
"(",
"strin... | // SafeUnmarshalBase64 first decodes the provided reader from base64 before decoding the xdr
// into the provided destination. Also ensures that the reader is fully consumed. | [
"SafeUnmarshalBase64",
"first",
"decodes",
"the",
"provided",
"reader",
"from",
"base64",
"before",
"decoding",
"the",
"xdr",
"into",
"the",
"provided",
"destination",
".",
"Also",
"ensures",
"that",
"the",
"reader",
"is",
"fully",
"consumed",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/main.go#L23-L40 | test |
stellar/go-stellar-base | xdr/main.go | SafeUnmarshal | func SafeUnmarshal(data []byte, dest interface{}) error {
r := bytes.NewReader(data)
n, err := Unmarshal(r, dest)
if err != nil {
return err
}
if n != len(data) {
return fmt.Errorf("input not fully consumed. expected to read: %d, actual: %d", len(data), n)
}
return nil
} | go | func SafeUnmarshal(data []byte, dest interface{}) error {
r := bytes.NewReader(data)
n, err := Unmarshal(r, dest)
if err != nil {
return err
}
if n != len(data) {
return fmt.Errorf("input not fully consumed. expected to read: %d, actual: %d", len(data), n)
}
return nil
} | [
"func",
"SafeUnmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"dest",
"interface",
"{",
"}",
")",
"error",
"{",
"r",
":=",
"bytes",
".",
"NewReader",
"(",
"data",
")",
"\n",
"n",
",",
"err",
":=",
"Unmarshal",
"(",
"r",
",",
"dest",
")",
"\n",
"if... | // SafeUnmarshal decodes the provided reader into the destination and verifies
// that provided bytes are all consumed by the unmarshalling process. | [
"SafeUnmarshal",
"decodes",
"the",
"provided",
"reader",
"into",
"the",
"destination",
"and",
"verifies",
"that",
"provided",
"bytes",
"are",
"all",
"consumed",
"by",
"the",
"unmarshalling",
"process",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/main.go#L44-L57 | test |
stellar/go-stellar-base | xdr/path_payment_result.go | SendAmount | func (pr *PathPaymentResult) SendAmount() Int64 {
s, ok := pr.GetSuccess()
if !ok {
return 0
}
if len(s.Offers) == 0 {
return s.Last.Amount
}
sa := s.Offers[0].AssetBought
var ret Int64
for _, o := range s.Offers {
if o.AssetBought.String() != sa.String() {
break
}
ret += o.AmountBought
}
ret... | go | func (pr *PathPaymentResult) SendAmount() Int64 {
s, ok := pr.GetSuccess()
if !ok {
return 0
}
if len(s.Offers) == 0 {
return s.Last.Amount
}
sa := s.Offers[0].AssetBought
var ret Int64
for _, o := range s.Offers {
if o.AssetBought.String() != sa.String() {
break
}
ret += o.AmountBought
}
ret... | [
"func",
"(",
"pr",
"*",
"PathPaymentResult",
")",
"SendAmount",
"(",
")",
"Int64",
"{",
"s",
",",
"ok",
":=",
"pr",
".",
"GetSuccess",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"0",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"Offers",
"... | // SendAmount returns the amount spent, denominated in the source asset, in the
// course of this path payment | [
"SendAmount",
"returns",
"the",
"amount",
"spent",
"denominated",
"in",
"the",
"source",
"asset",
"in",
"the",
"course",
"of",
"this",
"path",
"payment"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/path_payment_result.go#L5-L26 | test |
stellar/go-stellar-base | horizon/main.go | LoadAccount | func (c *Client) LoadAccount(accountID string) (account Account, err error) {
c.initHTTPClient()
resp, err := c.Client.Get(c.URL + "/accounts/" + accountID)
if err != nil {
return
}
err = decodeResponse(resp, &account)
return
} | go | func (c *Client) LoadAccount(accountID string) (account Account, err error) {
c.initHTTPClient()
resp, err := c.Client.Get(c.URL + "/accounts/" + accountID)
if err != nil {
return
}
err = decodeResponse(resp, &account)
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"LoadAccount",
"(",
"accountID",
"string",
")",
"(",
"account",
"Account",
",",
"err",
"error",
")",
"{",
"c",
".",
"initHTTPClient",
"(",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Client",
".",
"Get",
"(... | // LoadAccount loads the account state from horizon. err can be either error
// object or horizon.Error object. | [
"LoadAccount",
"loads",
"the",
"account",
"state",
"from",
"horizon",
".",
"err",
"can",
"be",
"either",
"error",
"object",
"or",
"horizon",
".",
"Error",
"object",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/horizon/main.go#L48-L57 | test |
stellar/go-stellar-base | horizon/main.go | SequenceForAccount | func (c *Client) SequenceForAccount(
accountID string,
) (xdr.SequenceNumber, error) {
a, err := c.LoadAccount(accountID)
if err != nil {
return 0, err
}
seq, err := strconv.ParseUint(a.Sequence, 10, 64)
if err != nil {
return 0, err
}
return xdr.SequenceNumber(seq), nil
} | go | func (c *Client) SequenceForAccount(
accountID string,
) (xdr.SequenceNumber, error) {
a, err := c.LoadAccount(accountID)
if err != nil {
return 0, err
}
seq, err := strconv.ParseUint(a.Sequence, 10, 64)
if err != nil {
return 0, err
}
return xdr.SequenceNumber(seq), nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SequenceForAccount",
"(",
"accountID",
"string",
",",
")",
"(",
"xdr",
".",
"SequenceNumber",
",",
"error",
")",
"{",
"a",
",",
"err",
":=",
"c",
".",
"LoadAccount",
"(",
"accountID",
")",
"\n",
"if",
"err",
"!=... | // SequenceForAccount implements build.SequenceProvider | [
"SequenceForAccount",
"implements",
"build",
".",
"SequenceProvider"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/horizon/main.go#L60-L75 | test |
stellar/go-stellar-base | horizon/main.go | SubmitTransaction | func (c *Client) SubmitTransaction(transactionEnvelopeXdr string) (response TransactionSuccess, err error) {
v := url.Values{}
v.Set("tx", transactionEnvelopeXdr)
c.initHTTPClient()
resp, err := c.Client.PostForm(c.URL+"/transactions", v)
if err != nil {
return
}
err = decodeResponse(resp, &response)
return... | go | func (c *Client) SubmitTransaction(transactionEnvelopeXdr string) (response TransactionSuccess, err error) {
v := url.Values{}
v.Set("tx", transactionEnvelopeXdr)
c.initHTTPClient()
resp, err := c.Client.PostForm(c.URL+"/transactions", v)
if err != nil {
return
}
err = decodeResponse(resp, &response)
return... | [
"func",
"(",
"c",
"*",
"Client",
")",
"SubmitTransaction",
"(",
"transactionEnvelopeXdr",
"string",
")",
"(",
"response",
"TransactionSuccess",
",",
"err",
"error",
")",
"{",
"v",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"v",
".",
"Set",
"(",
"\"tx\""... | // SubmitTransaction submits a transaction to the network. err can be either error object or horizon.Error object. | [
"SubmitTransaction",
"submits",
"a",
"transaction",
"to",
"the",
"network",
".",
"err",
"can",
"be",
"either",
"error",
"object",
"or",
"horizon",
".",
"Error",
"object",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/horizon/main.go#L78-L90 | test |
stellar/go-stellar-base | xdr/ledger_key.go | Equals | func (key *LedgerKey) Equals(other LedgerKey) bool {
if key.Type != other.Type {
return false
}
switch key.Type {
case LedgerEntryTypeAccount:
l := key.MustAccount()
r := other.MustAccount()
return l.AccountId.Equals(r.AccountId)
case LedgerEntryTypeData:
l := key.MustData()
r := other.MustData()
re... | go | func (key *LedgerKey) Equals(other LedgerKey) bool {
if key.Type != other.Type {
return false
}
switch key.Type {
case LedgerEntryTypeAccount:
l := key.MustAccount()
r := other.MustAccount()
return l.AccountId.Equals(r.AccountId)
case LedgerEntryTypeData:
l := key.MustData()
r := other.MustData()
re... | [
"func",
"(",
"key",
"*",
"LedgerKey",
")",
"Equals",
"(",
"other",
"LedgerKey",
")",
"bool",
"{",
"if",
"key",
".",
"Type",
"!=",
"other",
".",
"Type",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"key",
".",
"Type",
"{",
"case",
"LedgerEntryTy... | // Equals returns true if `other` is equivalent to `key` | [
"Equals",
"returns",
"true",
"if",
"other",
"is",
"equivalent",
"to",
"key"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_key.go#L11-L36 | test |
stellar/go-stellar-base | xdr/ledger_key.go | SetAccount | func (key *LedgerKey) SetAccount(account AccountId) error {
data := LedgerKeyAccount{account}
nkey, err := NewLedgerKey(LedgerEntryTypeAccount, data)
if err != nil {
return err
}
*key = nkey
return nil
} | go | func (key *LedgerKey) SetAccount(account AccountId) error {
data := LedgerKeyAccount{account}
nkey, err := NewLedgerKey(LedgerEntryTypeAccount, data)
if err != nil {
return err
}
*key = nkey
return nil
} | [
"func",
"(",
"key",
"*",
"LedgerKey",
")",
"SetAccount",
"(",
"account",
"AccountId",
")",
"error",
"{",
"data",
":=",
"LedgerKeyAccount",
"{",
"account",
"}",
"\n",
"nkey",
",",
"err",
":=",
"NewLedgerKey",
"(",
"LedgerEntryTypeAccount",
",",
"data",
")",
... | // SetAccount mutates `key` such that it represents the identity of `account` | [
"SetAccount",
"mutates",
"key",
"such",
"that",
"it",
"represents",
"the",
"identity",
"of",
"account"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_key.go#L39-L48 | test |
stellar/go-stellar-base | xdr/ledger_key.go | SetData | func (key *LedgerKey) SetData(account AccountId, name string) error {
data := LedgerKeyData{account, String64(name)}
nkey, err := NewLedgerKey(LedgerEntryTypeData, data)
if err != nil {
return err
}
*key = nkey
return nil
} | go | func (key *LedgerKey) SetData(account AccountId, name string) error {
data := LedgerKeyData{account, String64(name)}
nkey, err := NewLedgerKey(LedgerEntryTypeData, data)
if err != nil {
return err
}
*key = nkey
return nil
} | [
"func",
"(",
"key",
"*",
"LedgerKey",
")",
"SetData",
"(",
"account",
"AccountId",
",",
"name",
"string",
")",
"error",
"{",
"data",
":=",
"LedgerKeyData",
"{",
"account",
",",
"String64",
"(",
"name",
")",
"}",
"\n",
"nkey",
",",
"err",
":=",
"NewLedg... | // SetData mutates `key` such that it represents the identity of the
// data entry owned by `account` and for `name`. | [
"SetData",
"mutates",
"key",
"such",
"that",
"it",
"represents",
"the",
"identity",
"of",
"the",
"data",
"entry",
"owned",
"by",
"account",
"and",
"for",
"name",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_key.go#L52-L61 | test |
stellar/go-stellar-base | xdr/ledger_key.go | SetOffer | func (key *LedgerKey) SetOffer(account AccountId, id uint64) error {
data := LedgerKeyOffer{account, Uint64(id)}
nkey, err := NewLedgerKey(LedgerEntryTypeOffer, data)
if err != nil {
return err
}
*key = nkey
return nil
} | go | func (key *LedgerKey) SetOffer(account AccountId, id uint64) error {
data := LedgerKeyOffer{account, Uint64(id)}
nkey, err := NewLedgerKey(LedgerEntryTypeOffer, data)
if err != nil {
return err
}
*key = nkey
return nil
} | [
"func",
"(",
"key",
"*",
"LedgerKey",
")",
"SetOffer",
"(",
"account",
"AccountId",
",",
"id",
"uint64",
")",
"error",
"{",
"data",
":=",
"LedgerKeyOffer",
"{",
"account",
",",
"Uint64",
"(",
"id",
")",
"}",
"\n",
"nkey",
",",
"err",
":=",
"NewLedgerKe... | // SetOffer mutates `key` such that it represents the identity of the
// data entry owned by `account` and for offer `id`. | [
"SetOffer",
"mutates",
"key",
"such",
"that",
"it",
"represents",
"the",
"identity",
"of",
"the",
"data",
"entry",
"owned",
"by",
"account",
"and",
"for",
"offer",
"id",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_key.go#L65-L74 | test |
stellar/go-stellar-base | xdr/ledger_key.go | SetTrustline | func (key *LedgerKey) SetTrustline(account AccountId, line Asset) error {
data := LedgerKeyTrustLine{account, line}
nkey, err := NewLedgerKey(LedgerEntryTypeTrustline, data)
if err != nil {
return err
}
*key = nkey
return nil
} | go | func (key *LedgerKey) SetTrustline(account AccountId, line Asset) error {
data := LedgerKeyTrustLine{account, line}
nkey, err := NewLedgerKey(LedgerEntryTypeTrustline, data)
if err != nil {
return err
}
*key = nkey
return nil
} | [
"func",
"(",
"key",
"*",
"LedgerKey",
")",
"SetTrustline",
"(",
"account",
"AccountId",
",",
"line",
"Asset",
")",
"error",
"{",
"data",
":=",
"LedgerKeyTrustLine",
"{",
"account",
",",
"line",
"}",
"\n",
"nkey",
",",
"err",
":=",
"NewLedgerKey",
"(",
"L... | // SetTrustline mutates `key` such that it represents the identity of the
// trustline owned by `account` and for `asset`. | [
"SetTrustline",
"mutates",
"key",
"such",
"that",
"it",
"represents",
"the",
"identity",
"of",
"the",
"trustline",
"owned",
"by",
"account",
"and",
"for",
"asset",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_key.go#L78-L87 | test |
alecthomas/mph | chd_builder.go | Add | func (b *CHDBuilder) Add(key []byte, value []byte) {
b.keys = append(b.keys, key)
b.values = append(b.values, value)
} | go | func (b *CHDBuilder) Add(key []byte, value []byte) {
b.keys = append(b.keys, key)
b.values = append(b.values, value)
} | [
"func",
"(",
"b",
"*",
"CHDBuilder",
")",
"Add",
"(",
"key",
"[",
"]",
"byte",
",",
"value",
"[",
"]",
"byte",
")",
"{",
"b",
".",
"keys",
"=",
"append",
"(",
"b",
".",
"keys",
",",
"key",
")",
"\n",
"b",
".",
"values",
"=",
"append",
"(",
... | // Add a key and value to the hash table. | [
"Add",
"a",
"key",
"and",
"value",
"to",
"the",
"hash",
"table",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/chd_builder.go#L51-L54 | test |
alecthomas/mph | chd_builder.go | tryHash | func tryHash(hasher *chdHasher, seen map[uint64]bool, keys [][]byte, values [][]byte, indices []uint16, bucket *bucket, ri uint16, r uint64) bool {
// Track duplicates within this bucket.
duplicate := make(map[uint64]bool)
// Make hashes for each entry in the bucket.
hashes := make([]uint64, len(bucket.keys))
for ... | go | func tryHash(hasher *chdHasher, seen map[uint64]bool, keys [][]byte, values [][]byte, indices []uint16, bucket *bucket, ri uint16, r uint64) bool {
// Track duplicates within this bucket.
duplicate := make(map[uint64]bool)
// Make hashes for each entry in the bucket.
hashes := make([]uint64, len(bucket.keys))
for ... | [
"func",
"tryHash",
"(",
"hasher",
"*",
"chdHasher",
",",
"seen",
"map",
"[",
"uint64",
"]",
"bool",
",",
"keys",
"[",
"]",
"[",
"]",
"byte",
",",
"values",
"[",
"]",
"[",
"]",
"byte",
",",
"indices",
"[",
"]",
"uint16",
",",
"bucket",
"*",
"bucke... | // Try to find a hash function that does not cause collisions with table, when
// applied to the keys in the bucket. | [
"Try",
"to",
"find",
"a",
"hash",
"function",
"that",
"does",
"not",
"cause",
"collisions",
"with",
"table",
"when",
"applied",
"to",
"the",
"keys",
"in",
"the",
"bucket",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/chd_builder.go#L58-L89 | test |
alecthomas/mph | chd_builder.go | HashIndexFromKey | func (h *chdHasher) HashIndexFromKey(b []byte) uint64 {
return (hasher(b) ^ h.r[0]) % h.buckets
} | go | func (h *chdHasher) HashIndexFromKey(b []byte) uint64 {
return (hasher(b) ^ h.r[0]) % h.buckets
} | [
"func",
"(",
"h",
"*",
"chdHasher",
")",
"HashIndexFromKey",
"(",
"b",
"[",
"]",
"byte",
")",
"uint64",
"{",
"return",
"(",
"hasher",
"(",
"b",
")",
"^",
"h",
".",
"r",
"[",
"0",
"]",
")",
"%",
"h",
".",
"buckets",
"\n",
"}"
] | // Hash index from key. | [
"Hash",
"index",
"from",
"key",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/chd_builder.go#L187-L189 | test |
alecthomas/mph | slicereader_fast.go | ReadInt | func (b *sliceReader) ReadInt() uint64 {
return uint64(binary.LittleEndian.Uint32(b.Read(4)))
} | go | func (b *sliceReader) ReadInt() uint64 {
return uint64(binary.LittleEndian.Uint32(b.Read(4)))
} | [
"func",
"(",
"b",
"*",
"sliceReader",
")",
"ReadInt",
"(",
")",
"uint64",
"{",
"return",
"uint64",
"(",
"binary",
".",
"LittleEndian",
".",
"Uint32",
"(",
"b",
".",
"Read",
"(",
"4",
")",
")",
")",
"\n",
"}"
] | // Despite returning a uint64, this actually reads a uint32. All table indices
// and lengths are stored as uint32 values. | [
"Despite",
"returning",
"a",
"uint64",
"this",
"actually",
"reads",
"a",
"uint32",
".",
"All",
"table",
"indices",
"and",
"lengths",
"are",
"stored",
"as",
"uint32",
"values",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/slicereader_fast.go#L37-L39 | test |
alecthomas/mph | chd.go | Read | func Read(r io.Reader) (*CHD, error) {
b, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
return Mmap(b)
} | go | func Read(r io.Reader) (*CHD, error) {
b, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
return Mmap(b)
} | [
"func",
"Read",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"CHD",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
... | // Read a serialized CHD. | [
"Read",
"a",
"serialized",
"CHD",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/chd.go#L61-L67 | test |
alecthomas/mph | chd.go | Get | func (c *CHD) Get(key []byte) []byte {
r0 := c.r[0]
h := hasher(key) ^ r0
i := h % uint64(len(c.indices))
ri := c.indices[i]
// This can occur if there were unassigned slots in the hash table.
if ri >= uint16(len(c.r)) {
return nil
}
r := c.r[ri]
ti := (h ^ r) % uint64(len(c.keys))
// fmt.Printf("r[0]=%d, h... | go | func (c *CHD) Get(key []byte) []byte {
r0 := c.r[0]
h := hasher(key) ^ r0
i := h % uint64(len(c.indices))
ri := c.indices[i]
// This can occur if there were unassigned slots in the hash table.
if ri >= uint16(len(c.r)) {
return nil
}
r := c.r[ri]
ti := (h ^ r) % uint64(len(c.keys))
// fmt.Printf("r[0]=%d, h... | [
"func",
"(",
"c",
"*",
"CHD",
")",
"Get",
"(",
"key",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"r0",
":=",
"c",
".",
"r",
"[",
"0",
"]",
"\n",
"h",
":=",
"hasher",
"(",
"key",
")",
"^",
"r0",
"\n",
"i",
":=",
"h",
"%",
"uint64",
"(... | // Get an entry from the hash table. | [
"Get",
"an",
"entry",
"from",
"the",
"hash",
"table",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/chd.go#L99-L117 | test |
alecthomas/mph | chd.go | Iterate | func (c *CHD) Iterate() *Iterator {
if len(c.keys) == 0 {
return nil
}
return &Iterator{c: c}
} | go | func (c *CHD) Iterate() *Iterator {
if len(c.keys) == 0 {
return nil
}
return &Iterator{c: c}
} | [
"func",
"(",
"c",
"*",
"CHD",
")",
"Iterate",
"(",
")",
"*",
"Iterator",
"{",
"if",
"len",
"(",
"c",
".",
"keys",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"Iterator",
"{",
"c",
":",
"c",
"}",
"\n",
"}"
] | // Iterate over entries in the hash table. | [
"Iterate",
"over",
"entries",
"in",
"the",
"hash",
"table",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/chd.go#L124-L129 | test |
alecthomas/mph | chd.go | Write | func (c *CHD) Write(w io.Writer) error {
write := func(nd ...interface{}) error {
for _, d := range nd {
if err := binary.Write(w, binary.LittleEndian, d); err != nil {
return err
}
}
return nil
}
data := []interface{}{
uint32(len(c.r)), c.r,
uint32(len(c.indices)), c.indices,
uint32(len(c.key... | go | func (c *CHD) Write(w io.Writer) error {
write := func(nd ...interface{}) error {
for _, d := range nd {
if err := binary.Write(w, binary.LittleEndian, d); err != nil {
return err
}
}
return nil
}
data := []interface{}{
uint32(len(c.r)), c.r,
uint32(len(c.indices)), c.indices,
uint32(len(c.key... | [
"func",
"(",
"c",
"*",
"CHD",
")",
"Write",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"write",
":=",
"func",
"(",
"nd",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"for",
"_",
",",
"d",
":=",
"range",
"nd",
"{",
"if",
"err",
":="... | // Serialize the CHD. The serialized form is conducive to mmapped access. See
// the Mmap function for details. | [
"Serialize",
"the",
"CHD",
".",
"The",
"serialized",
"form",
"is",
"conducive",
"to",
"mmapped",
"access",
".",
"See",
"the",
"Mmap",
"function",
"for",
"details",
"."
] | cf7b0cd2d9579868ec2a49493fd62b2e28bcb336 | https://github.com/alecthomas/mph/blob/cf7b0cd2d9579868ec2a49493fd62b2e28bcb336/chd.go#L133-L166 | test |
omniscale/go-mapnik | mapnik.go | RegisterDatasources | func RegisterDatasources(path string) error {
cs := C.CString(path)
defer C.free(unsafe.Pointer(cs))
if C.mapnik_register_datasources(cs) == 0 {
e := C.GoString(C.mapnik_register_last_error())
if e != "" {
return errors.New("registering datasources: " + e)
}
return errors.New("error while registering data... | go | func RegisterDatasources(path string) error {
cs := C.CString(path)
defer C.free(unsafe.Pointer(cs))
if C.mapnik_register_datasources(cs) == 0 {
e := C.GoString(C.mapnik_register_last_error())
if e != "" {
return errors.New("registering datasources: " + e)
}
return errors.New("error while registering data... | [
"func",
"RegisterDatasources",
"(",
"path",
"string",
")",
"error",
"{",
"cs",
":=",
"C",
".",
"CString",
"(",
"path",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cs",
")",
")",
"\n",
"if",
"C",
".",
"mapnik_register_da... | // RegisterDatasources adds path to the Mapnik plugin search path. | [
"RegisterDatasources",
"adds",
"path",
"to",
"the",
"Mapnik",
"plugin",
"search",
"path",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L40-L51 | test |
omniscale/go-mapnik | mapnik.go | RegisterFonts | func RegisterFonts(path string) error {
cs := C.CString(path)
defer C.free(unsafe.Pointer(cs))
if C.mapnik_register_fonts(cs) == 0 {
e := C.GoString(C.mapnik_register_last_error())
if e != "" {
return errors.New("registering fonts: " + e)
}
return errors.New("error while registering fonts")
}
return nil... | go | func RegisterFonts(path string) error {
cs := C.CString(path)
defer C.free(unsafe.Pointer(cs))
if C.mapnik_register_fonts(cs) == 0 {
e := C.GoString(C.mapnik_register_last_error())
if e != "" {
return errors.New("registering fonts: " + e)
}
return errors.New("error while registering fonts")
}
return nil... | [
"func",
"RegisterFonts",
"(",
"path",
"string",
")",
"error",
"{",
"cs",
":=",
"C",
".",
"CString",
"(",
"path",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cs",
")",
")",
"\n",
"if",
"C",
".",
"mapnik_register_fonts",
... | // RegisterDatasources adds path to the Mapnik fonts search path. | [
"RegisterDatasources",
"adds",
"path",
"to",
"the",
"Mapnik",
"fonts",
"search",
"path",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L54-L65 | test |
omniscale/go-mapnik | mapnik.go | New | func New() *Map {
return &Map{
m: C.mapnik_map(C.uint(800), C.uint(600)),
width: 800,
height: 600,
}
} | go | func New() *Map {
return &Map{
m: C.mapnik_map(C.uint(800), C.uint(600)),
width: 800,
height: 600,
}
} | [
"func",
"New",
"(",
")",
"*",
"Map",
"{",
"return",
"&",
"Map",
"{",
"m",
":",
"C",
".",
"mapnik_map",
"(",
"C",
".",
"uint",
"(",
"800",
")",
",",
"C",
".",
"uint",
"(",
"600",
")",
")",
",",
"width",
":",
"800",
",",
"height",
":",
"600",... | // New initializes a new Map. | [
"New",
"initializes",
"a",
"new",
"Map",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L99-L105 | test |
omniscale/go-mapnik | mapnik.go | NewSized | func NewSized(width, height int) *Map {
return &Map{
m: C.mapnik_map(C.uint(width), C.uint(height)),
width: width,
height: height,
}
} | go | func NewSized(width, height int) *Map {
return &Map{
m: C.mapnik_map(C.uint(width), C.uint(height)),
width: width,
height: height,
}
} | [
"func",
"NewSized",
"(",
"width",
",",
"height",
"int",
")",
"*",
"Map",
"{",
"return",
"&",
"Map",
"{",
"m",
":",
"C",
".",
"mapnik_map",
"(",
"C",
".",
"uint",
"(",
"width",
")",
",",
"C",
".",
"uint",
"(",
"height",
")",
")",
",",
"width",
... | // NewSized initializes a new Map with the given size. | [
"NewSized",
"initializes",
"a",
"new",
"Map",
"with",
"the",
"given",
"size",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L108-L114 | test |
omniscale/go-mapnik | mapnik.go | Load | func (m *Map) Load(stylesheet string) error {
cs := C.CString(stylesheet)
defer C.free(unsafe.Pointer(cs))
if C.mapnik_map_load(m.m, cs) != 0 {
return m.lastError()
}
return nil
} | go | func (m *Map) Load(stylesheet string) error {
cs := C.CString(stylesheet)
defer C.free(unsafe.Pointer(cs))
if C.mapnik_map_load(m.m, cs) != 0 {
return m.lastError()
}
return nil
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"Load",
"(",
"stylesheet",
"string",
")",
"error",
"{",
"cs",
":=",
"C",
".",
"CString",
"(",
"stylesheet",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cs",
")",
")",
"\n",
"if",
... | // Load reads in a Mapnik map XML. | [
"Load",
"reads",
"in",
"a",
"Mapnik",
"map",
"XML",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L121-L128 | test |
omniscale/go-mapnik | mapnik.go | Resize | func (m *Map) Resize(width, height int) {
C.mapnik_map_resize(m.m, C.uint(width), C.uint(height))
m.width = width
m.height = height
} | go | func (m *Map) Resize(width, height int) {
C.mapnik_map_resize(m.m, C.uint(width), C.uint(height))
m.width = width
m.height = height
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"Resize",
"(",
"width",
",",
"height",
"int",
")",
"{",
"C",
".",
"mapnik_map_resize",
"(",
"m",
".",
"m",
",",
"C",
".",
"uint",
"(",
"width",
")",
",",
"C",
".",
"uint",
"(",
"height",
")",
")",
"\n",
"m",... | // Resize changes the map size in pixel.
// Sizes larger than 16k pixels are ignored by Mapnik. Use NewSized
// to initialize larger maps. | [
"Resize",
"changes",
"the",
"map",
"size",
"in",
"pixel",
".",
"Sizes",
"larger",
"than",
"16k",
"pixels",
"are",
"ignored",
"by",
"Mapnik",
".",
"Use",
"NewSized",
"to",
"initialize",
"larger",
"maps",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L133-L137 | test |
omniscale/go-mapnik | mapnik.go | Free | func (m *Map) Free() {
C.mapnik_map_free(m.m)
m.m = nil
} | go | func (m *Map) Free() {
C.mapnik_map_free(m.m)
m.m = nil
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"Free",
"(",
")",
"{",
"C",
".",
"mapnik_map_free",
"(",
"m",
".",
"m",
")",
"\n",
"m",
".",
"m",
"=",
"nil",
"\n",
"}"
] | // Free deallocates the map. | [
"Free",
"deallocates",
"the",
"map",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L140-L143 | test |
omniscale/go-mapnik | mapnik.go | SRS | func (m *Map) SRS() string {
return C.GoString(C.mapnik_map_get_srs(m.m))
} | go | func (m *Map) SRS() string {
return C.GoString(C.mapnik_map_get_srs(m.m))
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"SRS",
"(",
")",
"string",
"{",
"return",
"C",
".",
"GoString",
"(",
"C",
".",
"mapnik_map_get_srs",
"(",
"m",
".",
"m",
")",
")",
"\n",
"}"
] | // SRS returns the projection of the map. | [
"SRS",
"returns",
"the",
"projection",
"of",
"the",
"map",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L146-L148 | test |
omniscale/go-mapnik | mapnik.go | ZoomAll | func (m *Map) ZoomAll() error {
if C.mapnik_map_zoom_all(m.m) != 0 {
return m.lastError()
}
return nil
} | go | func (m *Map) ZoomAll() error {
if C.mapnik_map_zoom_all(m.m) != 0 {
return m.lastError()
}
return nil
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"ZoomAll",
"(",
")",
"error",
"{",
"if",
"C",
".",
"mapnik_map_zoom_all",
"(",
"m",
".",
"m",
")",
"!=",
"0",
"{",
"return",
"m",
".",
"lastError",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ZoomAll zooms to the maximum extent. | [
"ZoomAll",
"zooms",
"to",
"the",
"maximum",
"extent",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L163-L168 | test |
omniscale/go-mapnik | mapnik.go | ZoomTo | func (m *Map) ZoomTo(minx, miny, maxx, maxy float64) {
bbox := C.mapnik_bbox(C.double(minx), C.double(miny), C.double(maxx), C.double(maxy))
defer C.mapnik_bbox_free(bbox)
C.mapnik_map_zoom_to_box(m.m, bbox)
} | go | func (m *Map) ZoomTo(minx, miny, maxx, maxy float64) {
bbox := C.mapnik_bbox(C.double(minx), C.double(miny), C.double(maxx), C.double(maxy))
defer C.mapnik_bbox_free(bbox)
C.mapnik_map_zoom_to_box(m.m, bbox)
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"ZoomTo",
"(",
"minx",
",",
"miny",
",",
"maxx",
",",
"maxy",
"float64",
")",
"{",
"bbox",
":=",
"C",
".",
"mapnik_bbox",
"(",
"C",
".",
"double",
"(",
"minx",
")",
",",
"C",
".",
"double",
"(",
"miny",
")",
... | // ZoomTo zooms to the given bounding box. | [
"ZoomTo",
"zooms",
"to",
"the",
"given",
"bounding",
"box",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L171-L175 | test |
omniscale/go-mapnik | mapnik.go | Render | func (m *Map) Render(opts RenderOpts) ([]byte, error) {
scaleFactor := opts.ScaleFactor
if scaleFactor == 0.0 {
scaleFactor = 1.0
}
i := C.mapnik_map_render_to_image(m.m, C.double(opts.Scale), C.double(scaleFactor))
if i == nil {
return nil, m.lastError()
}
defer C.mapnik_image_free(i)
if opts.Format == "ra... | go | func (m *Map) Render(opts RenderOpts) ([]byte, error) {
scaleFactor := opts.ScaleFactor
if scaleFactor == 0.0 {
scaleFactor = 1.0
}
i := C.mapnik_map_render_to_image(m.m, C.double(opts.Scale), C.double(scaleFactor))
if i == nil {
return nil, m.lastError()
}
defer C.mapnik_image_free(i)
if opts.Format == "ra... | [
"func",
"(",
"m",
"*",
"Map",
")",
"Render",
"(",
"opts",
"RenderOpts",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"scaleFactor",
":=",
"opts",
".",
"ScaleFactor",
"\n",
"if",
"scaleFactor",
"==",
"0.0",
"{",
"scaleFactor",
"=",
"1.0",
"\n",... | // Render returns the map as an encoded image. | [
"Render",
"returns",
"the",
"map",
"as",
"an",
"encoded",
"image",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L301-L329 | test |
omniscale/go-mapnik | mapnik.go | RenderImage | func (m *Map) RenderImage(opts RenderOpts) (*image.NRGBA, error) {
scaleFactor := opts.ScaleFactor
if scaleFactor == 0.0 {
scaleFactor = 1.0
}
i := C.mapnik_map_render_to_image(m.m, C.double(opts.Scale), C.double(scaleFactor))
if i == nil {
return nil, m.lastError()
}
defer C.mapnik_image_free(i)
size := 0
... | go | func (m *Map) RenderImage(opts RenderOpts) (*image.NRGBA, error) {
scaleFactor := opts.ScaleFactor
if scaleFactor == 0.0 {
scaleFactor = 1.0
}
i := C.mapnik_map_render_to_image(m.m, C.double(opts.Scale), C.double(scaleFactor))
if i == nil {
return nil, m.lastError()
}
defer C.mapnik_image_free(i)
size := 0
... | [
"func",
"(",
"m",
"*",
"Map",
")",
"RenderImage",
"(",
"opts",
"RenderOpts",
")",
"(",
"*",
"image",
".",
"NRGBA",
",",
"error",
")",
"{",
"scaleFactor",
":=",
"opts",
".",
"ScaleFactor",
"\n",
"if",
"scaleFactor",
"==",
"0.0",
"{",
"scaleFactor",
"=",... | // RenderImage returns the map as an unencoded image.Image. | [
"RenderImage",
"returns",
"the",
"map",
"as",
"an",
"unencoded",
"image",
".",
"Image",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L332-L351 | test |
omniscale/go-mapnik | mapnik.go | RenderToFile | func (m *Map) RenderToFile(opts RenderOpts, path string) error {
scaleFactor := opts.ScaleFactor
if scaleFactor == 0.0 {
scaleFactor = 1.0
}
cs := C.CString(path)
defer C.free(unsafe.Pointer(cs))
var format *C.char
if opts.Format != "" {
format = C.CString(opts.Format)
} else {
format = C.CString("png256"... | go | func (m *Map) RenderToFile(opts RenderOpts, path string) error {
scaleFactor := opts.ScaleFactor
if scaleFactor == 0.0 {
scaleFactor = 1.0
}
cs := C.CString(path)
defer C.free(unsafe.Pointer(cs))
var format *C.char
if opts.Format != "" {
format = C.CString(opts.Format)
} else {
format = C.CString("png256"... | [
"func",
"(",
"m",
"*",
"Map",
")",
"RenderToFile",
"(",
"opts",
"RenderOpts",
",",
"path",
"string",
")",
"error",
"{",
"scaleFactor",
":=",
"opts",
".",
"ScaleFactor",
"\n",
"if",
"scaleFactor",
"==",
"0.0",
"{",
"scaleFactor",
"=",
"1.0",
"\n",
"}",
... | // RenderToFile writes the map as an encoded image to the file system. | [
"RenderToFile",
"writes",
"the",
"map",
"as",
"an",
"encoded",
"image",
"to",
"the",
"file",
"system",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L354-L372 | test |
omniscale/go-mapnik | mapnik.go | SetBufferSize | func (m *Map) SetBufferSize(s int) {
C.mapnik_map_set_buffer_size(m.m, C.int(s))
} | go | func (m *Map) SetBufferSize(s int) {
C.mapnik_map_set_buffer_size(m.m, C.int(s))
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"SetBufferSize",
"(",
"s",
"int",
")",
"{",
"C",
".",
"mapnik_map_set_buffer_size",
"(",
"m",
".",
"m",
",",
"C",
".",
"int",
"(",
"s",
")",
")",
"\n",
"}"
] | // SetBufferSize sets the pixel buffer at the map image edges where Mapnik should not render any labels. | [
"SetBufferSize",
"sets",
"the",
"pixel",
"buffer",
"at",
"the",
"map",
"image",
"edges",
"where",
"Mapnik",
"should",
"not",
"render",
"any",
"labels",
"."
] | 710dfcc5e486e5760d0a5c46be909d91968e1ffb | https://github.com/omniscale/go-mapnik/blob/710dfcc5e486e5760d0a5c46be909d91968e1ffb/mapnik.go#L375-L377 | test |
bcurren/go-ssdp | ssdp.go | Search | func Search(st string, mx time.Duration) ([]SearchResponse, error) {
conn, err := listenForSearchResponses()
if err != nil {
return nil, err
}
defer conn.Close()
searchBytes, broadcastAddr := buildSearchRequest(st, mx)
// Write search bytes on the wire so all devices can respond
_, err = conn.WriteTo(searchBy... | go | func Search(st string, mx time.Duration) ([]SearchResponse, error) {
conn, err := listenForSearchResponses()
if err != nil {
return nil, err
}
defer conn.Close()
searchBytes, broadcastAddr := buildSearchRequest(st, mx)
// Write search bytes on the wire so all devices can respond
_, err = conn.WriteTo(searchBy... | [
"func",
"Search",
"(",
"st",
"string",
",",
"mx",
"time",
".",
"Duration",
")",
"(",
"[",
"]",
"SearchResponse",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"listenForSearchResponses",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n... | // Search the network for SSDP devices using the given search string and duration
// to discover new devices. This function will return an array of SearchReponses
// discovered. | [
"Search",
"the",
"network",
"for",
"SSDP",
"devices",
"using",
"the",
"given",
"search",
"string",
"and",
"duration",
"to",
"discover",
"new",
"devices",
".",
"This",
"function",
"will",
"return",
"an",
"array",
"of",
"SearchReponses",
"discovered",
"."
] | ae8e7a0ef8a8f119ef439791570ee2a094d1d094 | https://github.com/bcurren/go-ssdp/blob/ae8e7a0ef8a8f119ef439791570ee2a094d1d094/ssdp.go#L47-L62 | test |
ctripcorp/ghost | pool/blockingPool.go | Get | func (p *blockingPool) Get() (net.Conn, error) {
//in case that pool is closed or pool.conns is set to nil
conns := p.conns
if conns == nil {
return nil, ErrClosed
}
select {
case conn := <-conns:
if time.Since(conn.start) > p.livetime {
if conn.Conn != nil {
conn.Conn.Close()
conn.Conn = nil
}... | go | func (p *blockingPool) Get() (net.Conn, error) {
//in case that pool is closed or pool.conns is set to nil
conns := p.conns
if conns == nil {
return nil, ErrClosed
}
select {
case conn := <-conns:
if time.Since(conn.start) > p.livetime {
if conn.Conn != nil {
conn.Conn.Close()
conn.Conn = nil
}... | [
"func",
"(",
"p",
"*",
"blockingPool",
")",
"Get",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"conns",
":=",
"p",
".",
"conns",
"\n",
"if",
"conns",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrClosed",
"\n",
"}",
"\n",
"select",
... | //Get blocks for an available connection. | [
"Get",
"blocks",
"for",
"an",
"available",
"connection",
"."
] | 9dce30d85194129b9c0ba6702c612f3b5c41d02f | https://github.com/ctripcorp/ghost/blob/9dce30d85194129b9c0ba6702c612f3b5c41d02f/pool/blockingPool.go#L55-L84 | test |
ctripcorp/ghost | pool/blockingPool.go | put | func (p *blockingPool) put(conn *WrappedConn) error {
//in case that pool is closed and pool.conns is set to nil
conns := p.conns
if conns == nil {
//conn.Conn is possibly nil coz factory() may fail, in which case conn is immediately
//put back to the pool
if conn.Conn != nil {
conn.Conn.Close()
conn.Co... | go | func (p *blockingPool) put(conn *WrappedConn) error {
//in case that pool is closed and pool.conns is set to nil
conns := p.conns
if conns == nil {
//conn.Conn is possibly nil coz factory() may fail, in which case conn is immediately
//put back to the pool
if conn.Conn != nil {
conn.Conn.Close()
conn.Co... | [
"func",
"(",
"p",
"*",
"blockingPool",
")",
"put",
"(",
"conn",
"*",
"WrappedConn",
")",
"error",
"{",
"conns",
":=",
"p",
".",
"conns",
"\n",
"if",
"conns",
"==",
"nil",
"{",
"if",
"conn",
".",
"Conn",
"!=",
"nil",
"{",
"conn",
".",
"Conn",
".",... | //put puts the connection back to the pool. If the pool is closed, put simply close
//any connections received and return immediately. A nil net.Conn is illegal and will be rejected. | [
"put",
"puts",
"the",
"connection",
"back",
"to",
"the",
"pool",
".",
"If",
"the",
"pool",
"is",
"closed",
"put",
"simply",
"close",
"any",
"connections",
"received",
"and",
"return",
"immediately",
".",
"A",
"nil",
"net",
".",
"Conn",
"is",
"illegal",
"... | 9dce30d85194129b9c0ba6702c612f3b5c41d02f | https://github.com/ctripcorp/ghost/blob/9dce30d85194129b9c0ba6702c612f3b5c41d02f/pool/blockingPool.go#L88-L112 | test |
go-audio/transforms | stereo.go | MonoToStereoF32 | func MonoToStereoF32(buf *audio.Float32Buffer) error {
if buf == nil || buf.Format == nil || buf.Format.NumChannels != 1 {
return audio.ErrInvalidBuffer
}
stereoData := make([]float32, len(buf.Data)*2)
var j int
for i := 0; i < len(buf.Data); i++ {
stereoData[j] = buf.Data[i]
j++
stereoData[j] = buf.Data[i... | go | func MonoToStereoF32(buf *audio.Float32Buffer) error {
if buf == nil || buf.Format == nil || buf.Format.NumChannels != 1 {
return audio.ErrInvalidBuffer
}
stereoData := make([]float32, len(buf.Data)*2)
var j int
for i := 0; i < len(buf.Data); i++ {
stereoData[j] = buf.Data[i]
j++
stereoData[j] = buf.Data[i... | [
"func",
"MonoToStereoF32",
"(",
"buf",
"*",
"audio",
".",
"Float32Buffer",
")",
"error",
"{",
"if",
"buf",
"==",
"nil",
"||",
"buf",
".",
"Format",
"==",
"nil",
"||",
"buf",
".",
"Format",
".",
"NumChannels",
"!=",
"1",
"{",
"return",
"audio",
".",
"... | // MonoToStereoF32 converts a mono stream into a stereo one
// by copying the mono signal to both channels in an interleaved
// signal. | [
"MonoToStereoF32",
"converts",
"a",
"mono",
"stream",
"into",
"a",
"stereo",
"one",
"by",
"copying",
"the",
"mono",
"signal",
"to",
"both",
"channels",
"in",
"an",
"interleaved",
"signal",
"."
] | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/stereo.go#L8-L23 | test |
go-audio/transforms | bit_crush.go | BitCrush | func BitCrush(buf *audio.FloatBuffer, factor float64) {
stepSize := crusherStepSize * factor
for i := 0; i < len(buf.Data); i++ {
frac, exp := math.Frexp(buf.Data[i])
frac = signum(frac) * math.Floor(math.Abs(frac)/stepSize+0.5) * stepSize
buf.Data[i] = math.Ldexp(frac, exp)
}
} | go | func BitCrush(buf *audio.FloatBuffer, factor float64) {
stepSize := crusherStepSize * factor
for i := 0; i < len(buf.Data); i++ {
frac, exp := math.Frexp(buf.Data[i])
frac = signum(frac) * math.Floor(math.Abs(frac)/stepSize+0.5) * stepSize
buf.Data[i] = math.Ldexp(frac, exp)
}
} | [
"func",
"BitCrush",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
",",
"factor",
"float64",
")",
"{",
"stepSize",
":=",
"crusherStepSize",
"*",
"factor",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"buf",
".",
"Data",
")",
";",
"i",
"++... | // BitCrush reduces the resolution of the sample to the target bit depth
// Note that bit crusher effects are usually made of this feature + a decimator | [
"BitCrush",
"reduces",
"the",
"resolution",
"of",
"the",
"sample",
"to",
"the",
"target",
"bit",
"depth",
"Note",
"that",
"bit",
"crusher",
"effects",
"are",
"usually",
"made",
"of",
"this",
"feature",
"+",
"a",
"decimator"
] | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/bit_crush.go#L17-L24 | test |
go-audio/transforms | normalize.go | NormalizeMax | func NormalizeMax(buf *audio.FloatBuffer) {
if buf == nil {
return
}
max := 0.0
for i := 0; i < len(buf.Data); i++ {
if math.Abs(buf.Data[i]) > max {
max = math.Abs(buf.Data[i])
}
}
if max != 0.0 {
for i := 0; i < len(buf.Data); i++ {
buf.Data[i] /= max
}
}
} | go | func NormalizeMax(buf *audio.FloatBuffer) {
if buf == nil {
return
}
max := 0.0
for i := 0; i < len(buf.Data); i++ {
if math.Abs(buf.Data[i]) > max {
max = math.Abs(buf.Data[i])
}
}
if max != 0.0 {
for i := 0; i < len(buf.Data); i++ {
buf.Data[i] /= max
}
}
} | [
"func",
"NormalizeMax",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
")",
"{",
"if",
"buf",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"max",
":=",
"0.0",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"buf",
".",
"Data",
")",
";",
... | // NormalizeMax sets the max value to 1 and normalize the rest of the data. | [
"NormalizeMax",
"sets",
"the",
"max",
"value",
"to",
"1",
"and",
"normalize",
"the",
"rest",
"of",
"the",
"data",
"."
] | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/normalize.go#L10-L27 | test |
go-audio/transforms | gain.go | Gain | func Gain(buf *audio.FloatBuffer, multiplier float64) error {
if buf == nil {
return audio.ErrInvalidBuffer
}
for i := 0; i < len(buf.Data); i++ {
buf.Data[i] *= multiplier
}
return nil
} | go | func Gain(buf *audio.FloatBuffer, multiplier float64) error {
if buf == nil {
return audio.ErrInvalidBuffer
}
for i := 0; i < len(buf.Data); i++ {
buf.Data[i] *= multiplier
}
return nil
} | [
"func",
"Gain",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
",",
"multiplier",
"float64",
")",
"error",
"{",
"if",
"buf",
"==",
"nil",
"{",
"return",
"audio",
".",
"ErrInvalidBuffer",
"\n",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
... | // Gain applies the multiplier to the passed buffer.
// A multipler of 1 would increase the amplitude of the signal by 100%
// while a multiplier of 0 would not do anything.
// Note that this is a very very naive implementation and we will more
// than add a more useful DB gain transform. | [
"Gain",
"applies",
"the",
"multiplier",
"to",
"the",
"passed",
"buffer",
".",
"A",
"multipler",
"of",
"1",
"would",
"increase",
"the",
"amplitude",
"of",
"the",
"signal",
"by",
"100%",
"while",
"a",
"multiplier",
"of",
"0",
"would",
"not",
"do",
"anything"... | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/gain.go#L10-L20 | test |
go-audio/transforms | mono.go | MonoDownmix | func MonoDownmix(buf *audio.FloatBuffer) error {
if buf == nil || buf.Format == nil {
return audio.ErrInvalidBuffer
}
nChans := buf.Format.NumChannels
if nChans < 2 {
return nil
}
nChansF := float64(nChans)
frameCount := buf.NumFrames()
newData := make([]float64, frameCount)
for i := 0; i < frameCount; i+... | go | func MonoDownmix(buf *audio.FloatBuffer) error {
if buf == nil || buf.Format == nil {
return audio.ErrInvalidBuffer
}
nChans := buf.Format.NumChannels
if nChans < 2 {
return nil
}
nChansF := float64(nChans)
frameCount := buf.NumFrames()
newData := make([]float64, frameCount)
for i := 0; i < frameCount; i+... | [
"func",
"MonoDownmix",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
")",
"error",
"{",
"if",
"buf",
"==",
"nil",
"||",
"buf",
".",
"Format",
"==",
"nil",
"{",
"return",
"audio",
".",
"ErrInvalidBuffer",
"\n",
"}",
"\n",
"nChans",
":=",
"buf",
".",
"... | // MonoDownmix converts the buffer to a mono buffer
// by downmixing the channels together. | [
"MonoDownmix",
"converts",
"the",
"buffer",
"to",
"a",
"mono",
"buffer",
"by",
"downmixing",
"the",
"channels",
"together",
"."
] | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/mono.go#L7-L30 | test |
go-audio/transforms | quantize.go | Quantize | func Quantize(buf *audio.FloatBuffer, bitDepth int) {
if buf == nil {
return
}
max := math.Pow(2, float64(bitDepth)) - 1
bufLen := len(buf.Data)
for i := 0; i < bufLen; i++ {
buf.Data[i] = round((buf.Data[i]+1)*max)/max - 1.0
}
} | go | func Quantize(buf *audio.FloatBuffer, bitDepth int) {
if buf == nil {
return
}
max := math.Pow(2, float64(bitDepth)) - 1
bufLen := len(buf.Data)
for i := 0; i < bufLen; i++ {
buf.Data[i] = round((buf.Data[i]+1)*max)/max - 1.0
}
} | [
"func",
"Quantize",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
",",
"bitDepth",
"int",
")",
"{",
"if",
"buf",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"max",
":=",
"math",
".",
"Pow",
"(",
"2",
",",
"float64",
"(",
"bitDepth",
")",
")",
"-... | // Quantize quantizes the audio signal to match the target bitDepth | [
"Quantize",
"quantizes",
"the",
"audio",
"signal",
"to",
"match",
"the",
"target",
"bitDepth"
] | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/quantize.go#L10-L20 | test |
go-audio/transforms | pcm_scale.go | PCMScale | func PCMScale(buf *audio.FloatBuffer, bitDepth int) error {
if buf == nil || buf.Format == nil {
return audio.ErrInvalidBuffer
}
factor := math.Pow(2, 8*float64(bitDepth/8)-1)
for i := 0; i < len(buf.Data); i++ {
buf.Data[i] *= factor
}
return nil
} | go | func PCMScale(buf *audio.FloatBuffer, bitDepth int) error {
if buf == nil || buf.Format == nil {
return audio.ErrInvalidBuffer
}
factor := math.Pow(2, 8*float64(bitDepth/8)-1)
for i := 0; i < len(buf.Data); i++ {
buf.Data[i] *= factor
}
return nil
} | [
"func",
"PCMScale",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
",",
"bitDepth",
"int",
")",
"error",
"{",
"if",
"buf",
"==",
"nil",
"||",
"buf",
".",
"Format",
"==",
"nil",
"{",
"return",
"audio",
".",
"ErrInvalidBuffer",
"\n",
"}",
"\n",
"factor",
... | // PCMScale converts a buffer with audio content from -1 to 1 into
// the PCM scale based on the passed bitdepth.
// Note that while the PCM data is scaled, the PCM format is not changed. | [
"PCMScale",
"converts",
"a",
"buffer",
"with",
"audio",
"content",
"from",
"-",
"1",
"to",
"1",
"into",
"the",
"PCM",
"scale",
"based",
"on",
"the",
"passed",
"bitdepth",
".",
"Note",
"that",
"while",
"the",
"PCM",
"data",
"is",
"scaled",
"the",
"PCM",
... | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/pcm_scale.go#L12-L22 | test |
go-audio/transforms | stereo_pan.go | StereoPan | func StereoPan(buf *audio.FloatBuffer, pan float64) error {
if buf == nil || buf.Format == nil || buf.Format.NumChannels != 2 {
return audio.ErrInvalidBuffer
}
if pan < 0 || pan > 1 {
return errors.New("invalid pan value, should be betwen 0 and 1")
}
if pan == 0.5 {
return nil
}
if pan < 0.5 {
for i := ... | go | func StereoPan(buf *audio.FloatBuffer, pan float64) error {
if buf == nil || buf.Format == nil || buf.Format.NumChannels != 2 {
return audio.ErrInvalidBuffer
}
if pan < 0 || pan > 1 {
return errors.New("invalid pan value, should be betwen 0 and 1")
}
if pan == 0.5 {
return nil
}
if pan < 0.5 {
for i := ... | [
"func",
"StereoPan",
"(",
"buf",
"*",
"audio",
".",
"FloatBuffer",
",",
"pan",
"float64",
")",
"error",
"{",
"if",
"buf",
"==",
"nil",
"||",
"buf",
".",
"Format",
"==",
"nil",
"||",
"buf",
".",
"Format",
".",
"NumChannels",
"!=",
"2",
"{",
"return",
... | // StereoPan changes the balance of the input buffer by "panning"
// more to the left or the right. The pan value must be between
// 0 and 1 where 0 is full first channel, 0.5 center and 1 full second channel.
// Note that the signal from 1 channel is not sent to the other, this transform
// only reduces the balance of... | [
"StereoPan",
"changes",
"the",
"balance",
"of",
"the",
"input",
"buffer",
"by",
"panning",
"more",
"to",
"the",
"left",
"or",
"the",
"right",
".",
"The",
"pan",
"value",
"must",
"be",
"between",
"0",
"and",
"1",
"where",
"0",
"is",
"full",
"first",
"ch... | 51830ccc35a5ce4be9d09b1d1f3f82dad376c240 | https://github.com/go-audio/transforms/blob/51830ccc35a5ce4be9d09b1d1f3f82dad376c240/stereo_pan.go#L14-L36 | test |
abronan/leadership | follower.go | Leader | func (f *Follower) Leader() string {
f.lock.Lock()
defer f.lock.Unlock()
return f.leader
} | go | func (f *Follower) Leader() string {
f.lock.Lock()
defer f.lock.Unlock()
return f.leader
} | [
"func",
"(",
"f",
"*",
"Follower",
")",
"Leader",
"(",
")",
"string",
"{",
"f",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"f",
".",
"leader",
"\n",
"}"
] | // Leader returns the current leader. | [
"Leader",
"returns",
"the",
"current",
"leader",
"."
] | 76df1b7fa3841b453d70d7183e8c02a87538c0ee | https://github.com/abronan/leadership/blob/76df1b7fa3841b453d70d7183e8c02a87538c0ee/follower.go#L33-L37 | test |
abronan/leadership | candidate.go | IsLeader | func (c *Candidate) IsLeader() bool {
c.lock.Lock()
defer c.lock.Unlock()
return c.leader
} | go | func (c *Candidate) IsLeader() bool {
c.lock.Lock()
defer c.lock.Unlock()
return c.leader
} | [
"func",
"(",
"c",
"*",
"Candidate",
")",
"IsLeader",
"(",
")",
"bool",
"{",
"c",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"c",
".",
"leader",
"\n",
"}"
] | // IsLeader returns true if the candidate is currently a leader. | [
"IsLeader",
"returns",
"true",
"if",
"the",
"candidate",
"is",
"currently",
"a",
"leader",
"."
] | 76df1b7fa3841b453d70d7183e8c02a87538c0ee | https://github.com/abronan/leadership/blob/76df1b7fa3841b453d70d7183e8c02a87538c0ee/candidate.go#L45-L49 | test |
DamienFontaine/lunarc | security/response.go | NewResponse | func NewResponse(clientID, redirectURI, userID, exp, code string) Response {
return Response{ClientID: clientID, RedirectURI: redirectURI, UserID: userID, Exp: exp, Code: code}
} | go | func NewResponse(clientID, redirectURI, userID, exp, code string) Response {
return Response{ClientID: clientID, RedirectURI: redirectURI, UserID: userID, Exp: exp, Code: code}
} | [
"func",
"NewResponse",
"(",
"clientID",
",",
"redirectURI",
",",
"userID",
",",
"exp",
",",
"code",
"string",
")",
"Response",
"{",
"return",
"Response",
"{",
"ClientID",
":",
"clientID",
",",
"RedirectURI",
":",
"redirectURI",
",",
"UserID",
":",
"userID",
... | //NewResponse returns a new OAuth2Response | [
"NewResponse",
"returns",
"a",
"new",
"OAuth2Response"
] | 2e7332a51f554794a549a313430eaa7dec8d13cc | https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/security/response.go#L29-L31 | test |
solher/snakepit | request_id.go | GetRequestID | func GetRequestID(ctx context.Context) (string, error) {
if ctx == nil {
return "", errors.New("nil context")
}
reqID, ok := ctx.Value(contextRequestID).(string)
if !ok {
return "", errors.New("unexpected type")
}
if len(reqID) == 0 {
return "", errors.New("empty value in context")
}
return reqID, nil
... | go | func GetRequestID(ctx context.Context) (string, error) {
if ctx == nil {
return "", errors.New("nil context")
}
reqID, ok := ctx.Value(contextRequestID).(string)
if !ok {
return "", errors.New("unexpected type")
}
if len(reqID) == 0 {
return "", errors.New("empty value in context")
}
return reqID, nil
... | [
"func",
"GetRequestID",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"\"\"",
",",
"errors",
".",
"New",
"(",
"\"nil context\"",
")",
"\n",
"}",
"\n",
"reqID",
",",
"ok",
... | // GetRequestID returns a request ID from the given context if one is present.
// Returns the empty string if a request ID cannot be found. | [
"GetRequestID",
"returns",
"a",
"request",
"ID",
"from",
"the",
"given",
"context",
"if",
"one",
"is",
"present",
".",
"Returns",
"the",
"empty",
"string",
"if",
"a",
"request",
"ID",
"cannot",
"be",
"found",
"."
] | bc2b6bc4ed85156fe5f715b058a30048c62f7ad5 | https://github.com/solher/snakepit/blob/bc2b6bc4ed85156fe5f715b058a30048c62f7ad5/request_id.go#L26-L41 | test |
jpillora/requestlog | writer.go | Log | func (m *monitorableWriter) Log() {
duration := time.Now().Sub(m.t0)
if m.Code == 0 {
m.Code = 200
}
if m.opts.Filter != nil && !m.opts.Filter(m.r, m.Code, duration, m.Size) {
return //skip
}
cc := m.colorCode()
size := ""
if m.Size > 0 {
size = sizestr.ToString(m.Size)
}
buff := bytes.Buffer{}
m.opts.... | go | func (m *monitorableWriter) Log() {
duration := time.Now().Sub(m.t0)
if m.Code == 0 {
m.Code = 200
}
if m.opts.Filter != nil && !m.opts.Filter(m.r, m.Code, duration, m.Size) {
return //skip
}
cc := m.colorCode()
size := ""
if m.Size > 0 {
size = sizestr.ToString(m.Size)
}
buff := bytes.Buffer{}
m.opts.... | [
"func",
"(",
"m",
"*",
"monitorableWriter",
")",
"Log",
"(",
")",
"{",
"duration",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"m",
".",
"t0",
")",
"\n",
"if",
"m",
".",
"Code",
"==",
"0",
"{",
"m",
".",
"Code",
"=",
"200",
"\n",
"... | //replace ResponseWriter with a monitorable one, return logger | [
"replace",
"ResponseWriter",
"with",
"a",
"monitorable",
"one",
"return",
"logger"
] | df8817be5f8288874e4cbe58d441a01222a28a2f | https://github.com/jpillora/requestlog/blob/df8817be5f8288874e4cbe58d441a01222a28a2f/writer.go#L81-L108 | test |
DamienFontaine/lunarc | smtp/util.go | SendMailSSL | func SendMailSSL(addr string, a smtp.Auth, from string, to []string, msg []byte) error {
conn, err := tls.Dial("tcp", addr, &tls.Config{InsecureSkipVerify: true}) //TODO: Not secure
if err != nil {
log.Println("Error Dialing", err)
return err
}
h, _, _ := net.SplitHostPort(addr)
c, err := smtp.NewClient(conn, ... | go | func SendMailSSL(addr string, a smtp.Auth, from string, to []string, msg []byte) error {
conn, err := tls.Dial("tcp", addr, &tls.Config{InsecureSkipVerify: true}) //TODO: Not secure
if err != nil {
log.Println("Error Dialing", err)
return err
}
h, _, _ := net.SplitHostPort(addr)
c, err := smtp.NewClient(conn, ... | [
"func",
"SendMailSSL",
"(",
"addr",
"string",
",",
"a",
"smtp",
".",
"Auth",
",",
"from",
"string",
",",
"to",
"[",
"]",
"string",
",",
"msg",
"[",
"]",
"byte",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"tls",
".",
"Dial",
"(",
"\"tcp\"",
",",... | // SendMailSSL envoie un email par SSL | [
"SendMailSSL",
"envoie",
"un",
"email",
"par",
"SSL"
] | 2e7332a51f554794a549a313430eaa7dec8d13cc | https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/smtp/util.go#L26-L70 | test |
DamienFontaine/lunarc | smtp/mail.go | Send | func (m *MailService) Send(message string, subject string, from string, to string) (err error) {
t := []string{to}
msg := []byte("From: " + from + "\r\n" +
"To: " + to + "\r\n" +
"Subject: " + subject + "\r\n" +
"\r\n" +
message + "\r\n")
err = m.SMTP.SendMail(from, t, msg)
return
} | go | func (m *MailService) Send(message string, subject string, from string, to string) (err error) {
t := []string{to}
msg := []byte("From: " + from + "\r\n" +
"To: " + to + "\r\n" +
"Subject: " + subject + "\r\n" +
"\r\n" +
message + "\r\n")
err = m.SMTP.SendMail(from, t, msg)
return
} | [
"func",
"(",
"m",
"*",
"MailService",
")",
"Send",
"(",
"message",
"string",
",",
"subject",
"string",
",",
"from",
"string",
",",
"to",
"string",
")",
"(",
"err",
"error",
")",
"{",
"t",
":=",
"[",
"]",
"string",
"{",
"to",
"}",
"\n",
"msg",
":=... | //Send envoie un email | [
"Send",
"envoie",
"un",
"email"
] | 2e7332a51f554794a549a313430eaa7dec8d13cc | https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/smtp/mail.go#L34-L45 | test |
malice-plugins/go-plugin-utils | waitforit/waitforit.go | WaitForIt | func WaitForIt(fullConn, host string, port, timeout int) error {
// fullConn := flag.String("full-connection", "", "full connection")
// host := flag.String("host", "", "host to connect")
// port := flag.Int("port", 80, "port to connect")
// timeout := flag.Int("timeout", 10, "time to wait until port become availab... | go | func WaitForIt(fullConn, host string, port, timeout int) error {
// fullConn := flag.String("full-connection", "", "full connection")
// host := flag.String("host", "", "host to connect")
// port := flag.Int("port", 80, "port to connect")
// timeout := flag.Int("timeout", 10, "time to wait until port become availab... | [
"func",
"WaitForIt",
"(",
"fullConn",
",",
"host",
"string",
",",
"port",
",",
"timeout",
"int",
")",
"error",
"{",
"conn",
":=",
"buildConn",
"(",
"host",
",",
"port",
",",
"fullConn",
")",
"\n",
"if",
"conn",
"==",
"nil",
"{",
"return",
"errors",
"... | // WaitForIt waits for a service or URL to become online | [
"WaitForIt",
"waits",
"for",
"a",
"service",
"or",
"URL",
"to",
"become",
"online"
] | 9ee76663c3b0a531b8c529f03f12a5a84ff9b61b | https://github.com/malice-plugins/go-plugin-utils/blob/9ee76663c3b0a531b8c529f03f12a5a84ff9b61b/waitforit/waitforit.go#L122-L156 | test |
DamienFontaine/lunarc | config/utils.go | Get | func Get(source interface{}, environment string, configEnv Environment) (conf interface{}, err error) {
if filename, ok := source.(string); ok {
source, err = ioutil.ReadFile(filename)
if err != nil {
log.Printf("Fatal: %v", err)
return
}
}
err = yaml.Unmarshal(source.([]byte), configEnv)
if err != nil... | go | func Get(source interface{}, environment string, configEnv Environment) (conf interface{}, err error) {
if filename, ok := source.(string); ok {
source, err = ioutil.ReadFile(filename)
if err != nil {
log.Printf("Fatal: %v", err)
return
}
}
err = yaml.Unmarshal(source.([]byte), configEnv)
if err != nil... | [
"func",
"Get",
"(",
"source",
"interface",
"{",
"}",
",",
"environment",
"string",
",",
"configEnv",
"Environment",
")",
"(",
"conf",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"if",
"filename",
",",
"ok",
":=",
"source",
".",
"(",
"string",... | // Get a config | [
"Get",
"a",
"config"
] | 2e7332a51f554794a549a313430eaa7dec8d13cc | https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/config/utils.go#L27-L48 | test |
solher/snakepit | root/root.go | initConfig | func initConfig() {
if cfgFile != "" { // enable ability to specify config file via flag
Viper.SetConfigFile(cfgFile)
}
Viper.SetConfigName("config") // name of config file (without extension)
Viper.AddConfigPath("$HOME") // adding home directory as first search path
Viper.AddConfigPath("./") // adding loc... | go | func initConfig() {
if cfgFile != "" { // enable ability to specify config file via flag
Viper.SetConfigFile(cfgFile)
}
Viper.SetConfigName("config") // name of config file (without extension)
Viper.AddConfigPath("$HOME") // adding home directory as first search path
Viper.AddConfigPath("./") // adding loc... | [
"func",
"initConfig",
"(",
")",
"{",
"if",
"cfgFile",
"!=",
"\"\"",
"{",
"Viper",
".",
"SetConfigFile",
"(",
"cfgFile",
")",
"\n",
"}",
"\n",
"Viper",
".",
"SetConfigName",
"(",
"\"config\"",
")",
"\n",
"Viper",
".",
"AddConfigPath",
"(",
"\"$HOME\"",
")... | // Read in config file and ENV variables if set. | [
"Read",
"in",
"config",
"file",
"and",
"ENV",
"variables",
"if",
"set",
"."
] | bc2b6bc4ed85156fe5f715b058a30048c62f7ad5 | https://github.com/solher/snakepit/blob/bc2b6bc4ed85156fe5f715b058a30048c62f7ad5/root/root.go#L37-L51 | test |
malice-plugins/go-plugin-utils | database/rethinkdb/rethinkdb.go | WritePluginResultsToDatabase | func WritePluginResultsToDatabase(results map[string]interface{}) {
// connect to RethinkDB
session, err := r.Connect(r.ConnectOpts{
Address: fmt.Sprintf("%s:28015", utils.Getopt("MALICE_RETHINKDB", "rethink")),
Timeout: 5 * time.Second,
Database: "malice",
})
if err != nil {
log.Debug(err)
return
}
... | go | func WritePluginResultsToDatabase(results map[string]interface{}) {
// connect to RethinkDB
session, err := r.Connect(r.ConnectOpts{
Address: fmt.Sprintf("%s:28015", utils.Getopt("MALICE_RETHINKDB", "rethink")),
Timeout: 5 * time.Second,
Database: "malice",
})
if err != nil {
log.Debug(err)
return
}
... | [
"func",
"WritePluginResultsToDatabase",
"(",
"results",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"session",
",",
"err",
":=",
"r",
".",
"Connect",
"(",
"r",
".",
"ConnectOpts",
"{",
"Address",
":",
"fmt",
".",
"Sprintf",
"(",
"\"%s:280... | // WritePluginResultsToDatabase upserts plugin results into Database | [
"WritePluginResultsToDatabase",
"upserts",
"plugin",
"results",
"into",
"Database"
] | 9ee76663c3b0a531b8c529f03f12a5a84ff9b61b | https://github.com/malice-plugins/go-plugin-utils/blob/9ee76663c3b0a531b8c529f03f12a5a84ff9b61b/database/rethinkdb/rethinkdb.go#L23-L58 | test |
DamienFontaine/lunarc | security/controller.go | NewAuthController | func NewAuthController(um UserManager, cnf web.Config) *AuthController {
authController := AuthController{UserManager: um, cnf: cnf}
return &authController
} | go | func NewAuthController(um UserManager, cnf web.Config) *AuthController {
authController := AuthController{UserManager: um, cnf: cnf}
return &authController
} | [
"func",
"NewAuthController",
"(",
"um",
"UserManager",
",",
"cnf",
"web",
".",
"Config",
")",
"*",
"AuthController",
"{",
"authController",
":=",
"AuthController",
"{",
"UserManager",
":",
"um",
",",
"cnf",
":",
"cnf",
"}",
"\n",
"return",
"&",
"authControll... | //NewAuthController constructs new AuthController | [
"NewAuthController",
"constructs",
"new",
"AuthController"
] | 2e7332a51f554794a549a313430eaa7dec8d13cc | https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/security/controller.go#L39-L42 | test |
DamienFontaine/lunarc | security/controller.go | Authenticate | func (c *AuthController) Authenticate(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
var user User
var data map[string]string
err := decoder.Decode(&user)
if err != nil {
http.Error(w, fmt.Sprintf("%v", err), 400)
return
}
user, _ = c.UserManager.Get(user.Username, user.Password... | go | func (c *AuthController) Authenticate(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
var user User
var data map[string]string
err := decoder.Decode(&user)
if err != nil {
http.Error(w, fmt.Sprintf("%v", err), 400)
return
}
user, _ = c.UserManager.Get(user.Username, user.Password... | [
"func",
"(",
"c",
"*",
"AuthController",
")",
"Authenticate",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"decoder",
":=",
"json",
".",
"NewDecoder",
"(",
"r",
".",
"Body",
")",
"\n",
"var",
"user",
"User... | //Authenticate controls authorizations | [
"Authenticate",
"controls",
"authorizations"
] | 2e7332a51f554794a549a313430eaa7dec8d13cc | https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/security/controller.go#L45-L69 | test |
DamienFontaine/lunarc | security/controller.go | NewOAuth2Controller | func NewOAuth2Controller(am ApplicationManager, cnf web.Config) *OAuth2Controller {
oAuth2Controller := OAuth2Controller{cnf: cnf, ApplicationManager: am}
return &oAuth2Controller
} | go | func NewOAuth2Controller(am ApplicationManager, cnf web.Config) *OAuth2Controller {
oAuth2Controller := OAuth2Controller{cnf: cnf, ApplicationManager: am}
return &oAuth2Controller
} | [
"func",
"NewOAuth2Controller",
"(",
"am",
"ApplicationManager",
",",
"cnf",
"web",
".",
"Config",
")",
"*",
"OAuth2Controller",
"{",
"oAuth2Controller",
":=",
"OAuth2Controller",
"{",
"cnf",
":",
"cnf",
",",
"ApplicationManager",
":",
"am",
"}",
"\n",
"return",
... | //NewOAuth2Controller constructs new AuthController | [
"NewOAuth2Controller",
"constructs",
"new",
"AuthController"
] | 2e7332a51f554794a549a313430eaa7dec8d13cc | https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/security/controller.go#L78-L81 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.