id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c181900 |
split := strings.Split(keyVal, "=")
m[split[0]] = true
}
name = flagAsEnv(name)
if _, ok = m[name]; ok {
s = os.Getenv(name)
}
return
} | |
c181901 | name = strings.Replace(name, "-", "_", -1)
return name
} | |
c181902 | MinSpclChars: 0,
LowerPool: "abcdefghijklmnopqrstuvwxyz",
UpperPool: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
DigitPool: "0123456789",
SpclCharPool: "!@#$%^&*()-_=+,.?/:;{}[]~",
}
return p
} | |
c181903 | max := len(bs)
for i := 0; i < length; i++ {
Shuffle(bs)
filled[i] = bs[random(0, max)]
}
return filled
} | |
c181904 | {
rand.Seed(time.Now().UnixNano())
j := rand.Intn(i + 1)
bs[i], bs[j] = bs[j], bs[i]
}
} | |
c181905 | p.MaxLength {
return "", ErrMaxLengthExceeded
}
if p.MaxLength == 0 {
return "", nil
}
capsAlpha := []byte(p.UpperPool)
smallAlpha := []byte(p.LowerPool)
digits := []byte(p.DigitPool)
spclChars := []byte(p.SpclCharPool)
allChars := []byte(p.UpperPool + p.LowerPool + p.DigitPool + p.SpclCharPool)
passwd := CreateRandom(capsAlpha, p.MinUppers)
passwd = append(passwd, CreateRandom(smallAlpha, p.MinLowers)...)
passwd = append(passwd, CreateRandom(digits, p.MinDigits)...)
passwd = append(passwd, CreateRandom(spclChars, p.MinSpclChars)...)
passLen := len(passwd)
if passLen < p.MaxLength {
randLength := random(p.MinLength, p.MaxLength)
passwd = append(passwd, CreateRandom(allChars, randLength-passLen)...)
}
Shuffle(passwd)
return string(passwd), nil
} | |
c181906 | "", err
}
folder, _ := filepath.Split(p)
return folder, nil
} | |
c181907 |
s.ignoreErrors = append(s.ignoreErrors, ignore...)
return nil
}
} | |
c181908 | {
return ErrAlreadyStarted
}
s.shutdownSigs = sigs
return nil
}
} | |
c181909 | *Sentinel) error {
s.logf = f
return nil
}
} | |
c181910 | *Sentinel) error {
s.errf = f
return nil
}
} | |
c181911 | {
s.shutdownSigs = []os.Signal{os.Interrupt}
}
// ensure errf set
if s.errf == nil {
s.errf = func(str string, v ...interface{}) {
s.logf("ERROR: "+str, v...)
}
}
return s, nil
} | |
c181912 |
s.sig = make(chan os.Signal, 1)
signal.Notify(s.sig, s.shutdownSigs...)
return func() error {
s.logf("received signal: %v", <-s.sig)
return s.Shutdown()
}
}())
if err := eg.Wait(); err != nil && !s.ShutdownIgnore(err) {
return err
}
return nil
} | |
c181913 | s.errf("could not shutdown %d: %v", i, err)
if firstErr == nil {
firstErr = err
}
}
}
return firstErr
} | |
c181914 | s.ignoreErrors {
if z := f(err); z {
return true
}
}
return false
} | |
c181915 |
if err != nil {
return err
}
s.shutdownFuncs, err = convertAndAppendContextFuncs(s.shutdownFuncs, shutdown)
if err != nil {
return err
}
s.ignoreErrors = append(s.ignoreErrors, ignore...)
return nil
} | |
c181916 | return nil, err
}
// register server + shutdown
if err = s.Register(mux, mux, IgnoreListenerClosed, IgnoreNetOpError); err != nil {
return nil, err
}
return mux, nil
} | |
c181917 | err
}
}
// register server
return s.Register(func() error {
return server.Serve(listener)
}, server.Shutdown, IgnoreServerClosed, IgnoreNetOpError)
} | |
c181918 | func(e error) bool {
return err == e
}
} | |
c181919 | ok {
return opErr.Err.Error() == "use of closed network connection"
}
return false
} | |
c181920 |
}
case func() error:
t = func(context.Context) error {
return f()
}
}
if t == nil {
return nil, ErrInvalidType
}
o = append(o, t)
}
return o, nil
} | |
c181921 | } else {
m.HandleFunc(api.DefaultPath, endpoint.ServeHTTP)
}
}
m.HandleFunc("/__health", healthHandler)
// The top one of these feels more correct, but the lower one matches what we have in Dropwizard,
// so it's what apps expect currently
m.HandleFunc(status.PingPath, status.PingHandler)
m.HandleFunc(status.PingPathDW, status.PingHandler)
// The top one of these feels more correct, but the lower one matches what we have in Dropwizard,
// so it's what apps expect currently same as ping, the content of build-info needs more definition
m.HandleFunc(status.BuildInfoPath, status.BuildInfoHandler)
m.HandleFunc(status.BuildInfoPathDW, status.BuildInfoHandler)
m.HandleFunc(status.GTGPath, status.NewGoodToGoHandler(gtg.FailFastParallelCheck(gtgChecker)))
return m
} | |
c181922 | fmt.Fprintf(w, "build-info")
} | |
c181923 | if t.Kind() == reflect.Struct {
result = copyStruct(reflect.ValueOf(data), t).Interface()
} else {
result = data
}
b, err := json.Marshal(result)
return b, err
} | |
c181924 |
}
if err := json.NewDecoder(req.Body).Decode(jsonStruct.Interface()); err != nil {
errors.Overall[DeserializationError] = err.Error()
}
validateAndMap(jsonStruct, context, errors, ifacePtr...)
}
} | |
c181925 |
context.Map(obj.Elem().Interface())
if len(ifacePtr) > 0 {
context.MapTo(obj.Elem().Interface(), ifacePtr[0])
}
} | |
c181926 | len(self.Overall) + len(self.Fields)
} | |
c181927 | // TODO: Add default headers
headers[headerAllowHeaders] = strings.Join(o.AllowHeaders, ",")
}
// add exposed header
if len(o.ExposeHeaders) > 0 {
headers[headerExposeHeaders] = strings.Join(o.ExposeHeaders, ",")
}
// add a max age header
if o.MaxAge > time.Duration(0) {
headers[headerMaxAge] = strconv.FormatInt(int64(o.MaxAge/time.Second), 10)
}
return
} | |
c181928 | var allowed []string
for _, rHeader := range strings.Split(rHeaders, ",") {
lookupLoop:
for _, allowedHeader := range o.AllowHeaders {
if rHeader == allowedHeader {
allowed = append(allowed, rHeader)
break lookupLoop
}
}
}
// add allowed headers
if len(allowed) > 0 {
headers[headerAllowHeaders] = strings.Join(allowed, ",")
}
// add exposed headers
if len(o.ExposeHeaders) > 0 {
headers[headerExposeHeaders] = strings.Join(o.ExposeHeaders, ",")
}
// add a max age header
if o.MaxAge > time.Duration(0) {
headers[headerMaxAge] = strconv.FormatInt(int64(o.MaxAge/time.Second), 10)
}
return
} | |
c181929 | regexp.MatchString(pattern, origin)
if allowed {
return
}
}
return
} | |
c181930 | "") {
// TODO: if preflight, respond with exact headers if allowed
headers = opts.PreflightHeader(origin, requestedMethod, requestedHeaders)
} else {
headers = opts.Header(origin)
}
for key, value := range headers {
res.Header().Set(key, value)
}
}
} | |
c181931 | *http.Request, c martini.Context) {
// recompile for easy development
if martini.Env == martini.Dev {
t = compile(opt)
}
tc, _ := t.Clone()
c.MapTo(&renderer{res, req, tc, opt, cs}, (*Render)(nil))
}
} | |
c181932 | {
output.WriteString(", ")
}
}
if output.Len() == 0 {
output.WriteString("[]")
}
return output.String()
} | |
c181933 | {
quality, error := strconv.ParseFloat(qualifiedRange[1], 32)
if error != nil {
// When the quality is unparseable, assume it's 1
acceptLanguages[i] = AcceptLanguage{trimLanguage(qualifiedRange[0]), 1}
} else {
acceptLanguages[i] = AcceptLanguage{trimLanguage(qualifiedRange[0]), float32(quality)}
}
} else {
acceptLanguages[i] = AcceptLanguage{trimLanguage(languageRange), 1}
}
}
sort.Sort(acceptLanguages)
context.Map(acceptLanguages)
} else {
// If we have no Accept-Language header just map an empty slice
context.Map(make(AcceptLanguages, 0))
}
}
} | |
c181934 | "" {
return
}
if p := strings.TrimPrefix(r.URL.Path, prefix); len(p) < len(r.URL.Path) {
r.URL.Path = p
} else {
http.NotFound(w, r)
}
}
} | |
c181935 | res.Header().Set("WWW-Authenticate", "Basic realm=\"Authorization Required\"")
http.Error(res, "Not Authorized", http.StatusUnauthorized)
}
}
} | |
c181936 | error {
s.Set(SessionKey, user.UniqueId())
return nil
} | |
c181937 | "SELECT * FROM users WHERE id = $1", id)
if err != nil {
return err
}
return nil
} | |
c181938 | copy(raw[:], bytes)
pk, err := xdr.NewPublicKey(xdr.CryptoKeyTypeKeyTypeEd25519, raw)
if err != nil {
return
}
result = xdr.AccountId(pk)
return
} | |
c181939 | m.Native {
return errors.New("Native asset not allowed")
}
o.Line, err = m.ToXdrObject()
return
} | |
c181940 | o.Limit, err = amount.Parse(string(m))
return
} | |
c181941 | _, isLimit := mut.(Limit)
if isLimit {
limitSet = true
}
}
if !limitSet {
mutators = append(mutators, MaxLimit)
}
return ChangeTrust(mutators...)
} | |
c181942 | CreditAsset(code, issuer),
Limit("0"),
}
for _, mut := range args {
mutators = append(mutators, mut)
}
return ChangeTrust(mutators...)
} | |
c181943 | err = createAlphaNumAsset(m.Code, m.Issuer)
case *xdr.PathPaymentOp:
o.DestAmount, err = amount.Parse(m.Amount)
if err != nil {
return
}
o.DestAsset, err = createAlphaNumAsset(m.Code, m.Issuer)
}
return
} | |
c181944 |
case *xdr.PathPaymentOp:
return setAccountId(m.AddressOrSeed, &o.Destination)
}
return nil
} | |
c181945 | err = xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
case *xdr.PathPaymentOp:
o.DestAmount, err = amount.Parse(m.Amount)
if err != nil {
return
}
o.DestAsset, err = xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
}
return
} | |
c181946 | xdrAsset, err = asset.ToXdrObject()
if err != nil {
return err
}
path = append(path, xdrAsset)
}
pathPaymentOp.Path = path
// Asset
pathPaymentOp.SendAsset, err = m.Asset.ToXdrObject()
return
} | |
c181947 | setAccountId(m.AddressOrSeed, &o.Destination)
} | |
c181948 | err := Parse(v)
if err != nil {
panic(err)
}
return ret
} | |
c181949 | i, err := strconv.ParseInt(is, 10, 64)
if err != nil {
return xdr.Int64(0), err
}
return xdr.Int64(i), nil
} | |
c181950 | o.SetInt64(One)
r.Quo(&f, &o)
return r.FloatString(7)
} | |
c181951 | ManageOffer(false, rate, amount)
} | |
c181952 | return ManageOffer(true, rate, amount)
} | |
c181953 | return ManageOffer(false, rate, amount, offerID)
} | |
c181954 | ManageOffer(false, rate, Amount("0"), offerID)
} | |
c181955 | = passiveOffer
result.Mutate(muts...)
return
} | |
c181956 | err = mut.MutateManageOffer(&b.PO)
} else {
err = mut.MutateManageOffer(&b.MO)
}
case OperationMutator:
err = mut.MutateOperation(&b.O)
default:
err = errors.New("Mutator type not allowed")
}
if err != nil {
b.Err = err
return
}
}
} | |
c181957 | = amount.Parse(string(m))
case *xdr.CreatePassiveOfferOp:
o.Amount, err = amount.Parse(string(m))
}
return
} | |
c181958 | type")
case *xdr.ManageOfferOp:
o.OfferId = xdr.Uint64(m)
}
return
} | |
c181959 | m.Selling.ToXdrObject()
if err != nil {
return
}
o.Buying, err = m.Buying.ToXdrObject()
if err != nil {
return
}
o.Price, err = price.Parse(string(m.Price))
}
return
} | |
c181960 | {
o.SourceAccount = &xdr.AccountId{}
return setAccountId(m.AddressOrSeed, o.SourceAccount)
} | |
c181961 | big.NewRat(int64(p.N), int64(p.D)).FloatString(7)
} | |
c181962 | &TransactionBuilder{}
result.Mutate(muts...)
result.Mutate(Defaults{})
return
} | |
c181963 | &xdr.Transaction{}
}
for _, m := range muts {
err := m.MutateTransaction(b)
if err != nil {
b.Err = err
return
}
}
} | |
c181964 | return [32]byte{}, err
}
_, err = xdr.Marshal(&txBytes, b.TX)
if err != nil {
return [32]byte{}, err
}
return hash.Hash(txBytes.Bytes()), nil
} | |
c181965 | return "", err
}
return hex.EncodeToString(hash[:]), nil
} | |
c181966 | range signers {
result.Mutate(Sign{s})
}
return
} | |
c181967 | m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeAllowTrust, m.AT)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | |
c181968 | m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeChangeTrust, m.CT)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | |
c181969 | m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeCreateAccount, m.CA)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | |
c181970 | o.NetworkID == [32]byte{} {
o.NetworkID = DefaultNetwork.ID()
}
return nil
} | |
c181971 | m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeInflation, nil)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | |
c181972 | m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeManageData, m.MD)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | |
c181973 |
o.TX.Operations = append(o.TX.Operations, m.O)
} else {
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeManageOffer, m.MO)
o.TX.Operations = append(o.TX.Operations, m.O)
}
return m.Err
} | |
c181974 | (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoHash, m.Value)
return
} | |
c181975 | err = xdr.NewMemo(xdr.MemoTypeMemoId, xdr.Uint64(m.Value))
return
} | |
c181976 | (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoReturn, m.Value)
return
} | |
c181977 | 28 bytes")
return
}
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoText, m.Value)
return
} | |
c181978 | error {
o.NetworkID = m.ID()
return nil
} | |
c181979 |
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypePayment, m.P)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | |
c181980 | m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeSetOptions, m.SO)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | |
c181981 | = xdr.SequenceNumber(m.Sequence)
return nil
} | |
c181982 | setAccountId(m.AddressOrSeed, &o.TX.SourceAccount)
} | |
c181983 | for xdr.Int64")
}
*t = Int64(val)
return nil
} | |
c181984 |
if first.Type != xdr.LedgerEntryChangeTypeLedgerEntryState {
return nil, nil
}
result := first.MustState()
return &result, nil
} | |
c181985 | []xdr.LedgerEntryChange) {
return b.changes(target, math.MaxInt32)
} | |
c181986 |
// retrieving changes from the end of the collection. If this situation
// occurs, it means that I didn't understand something correctly or there is
// a bug in stellar-core.
panic(fmt.Errorf("Unexpected 'state' entry"))
default:
panic(fmt.Errorf("Unknown change type: %v", change.Type))
}
} | |
c181987 |
for _, change := range op.Changes {
key := change.LedgerKey()
if !key.Equals(target) {
continue
}
ret = append(ret, change)
}
}
return
} | |
c181988 | err != nil {
panic(err)
}
return d
} | |
c181989 | // calculate and write checksum
checksum := crc16.Checksum(raw.Bytes())
if _, err := raw.Write(checksum); err != nil {
return "", err
}
result := base32.StdEncoding.EncodeToString(raw.Bytes())
return result, nil
} | |
c181990 | err != nil {
panic(err)
}
return e
} | |
c181991 | version == VersionByteSeed {
return nil
}
return ErrInvalidVersionByte
} | |
c181992 |
err := binary.Write(&out, binary.LittleEndian, crc)
if err != nil {
panic(err)
}
return out.Bytes()
} | |
c181993 | the provided checksum against the calculated
if !bytes.Equal(actual, expected) {
return ErrInvalidChecksum
}
return nil
} | |
c181994 | LedgerEntryChangeTypeLedgerEntryState:
change := change.MustState()
return change.LedgerKey()
default:
panic(fmt.Errorf("Unknown change type: %v", change.Type))
}
} | |
c181995 | not in the base32 alphabet\n", strconv.QuoteRune(r))
os.Exit(1)
}
}
} | |
c181996 | copy(raw, ed[:])
return strkey.MustEncode(strkey.VersionByteAccountID, raw)
default:
panic(fmt.Errorf("Unknown account id type: %v", aid.Type))
}
} | |
c181997 | case CryptoKeyTypeKeyTypeEd25519:
l := aid.MustEd25519()
r := other.MustEd25519()
return l == r
default:
panic(fmt.Errorf("Unknown account id type: %v", aid.Type))
}
} | |
c181998 | 32 {
return errors.New("invalid address")
}
var ui Uint256
copy(ui[:], raw)
*aid, err = NewAccountId(CryptoKeyTypeKeyTypeEd25519, ui)
return err
} | |
c181999 |
copy(codeArray[:], byteArray[0:length])
asset := xdr.AssetAlphaNum4{codeArray, issuer}
return xdr.NewAsset(xdr.AssetTypeAssetTypeCreditAlphanum4, asset)
case length >= 5 && length <= 12:
var codeArray [12]byte
byteArray := []byte(a.Code)
copy(codeArray[:], byteArray[0:length])
asset := xdr.AssetAlphaNum12{codeArray, issuer}
return xdr.NewAsset(xdr.AssetTypeAssetTypeCreditAlphanum12, asset)
default:
return xdr.Asset{}, errors.New("Asset code length is invalid")
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.