// GoCode returns a string of rendered GoCode for this Operation
356606
func (o *Operation) GoCode() string {
	var buf bytes.Buffer

	if len(o.OutputRef.Shape.EventStreamsMemberName) != 0 {
		o.API.AddSDKImport("aws/client")
		o.API.AddSDKImport("private/protocol")
		o.API.AddSDKImport("private/protocol/rest")
		o.API.AddSDKImport("private/protocol", o.API.ProtocolPackage())
	}

	if o.API.EndpointDiscoveryOp != nil {
		o.API.AddSDKImport("aws/crr")
		o.API.AddImport("time")
		o.API.AddImport("net/url")
	}

	if o.Endpoint != nil && len(o.Endpoint.HostPrefix) != 0 {
		setupEndpointHostPrefix(o)
	}

	err := operationTmpl.Execute(&buf, o)
	if err != nil {
		panic(err)
	}

	return strings.TrimSpace(buf.String())
}
631733
func (vs ShapeValidations) GoCode(shape *Shape) string {
	buf := &bytes.Buffer{}
	validateShapeTmpl.Execute(buf, map[string]interface{}{
		"Shape":       shape,
		"Validations": vs,
	})
	return buf.String()
}
1186353
func (g GobEncoder) Encode(v interface{}) ([]byte, error) {
	var buf bytes.Buffer
	e := gob.NewEncoder(&buf)
	err := e.Encode(v)
	return buf.Bytes(), err
}
962250
func (h *HyperLogLog) GobEncode() ([]byte, error) {
	buf := bytes.Buffer{}
	enc := gob.NewEncoder(&buf)
	if err := enc.Encode(h.reg); err != nil {
		return nil, err
	}
	if err := enc.Encode(h.m); err != nil {
		return nil, err
	}
	if err := enc.Encode(h.p); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
598690
func goCode(b []byte, f *ast.File) []byte {
	furthestPos := f.Name.End()
	for _, node := range f.Imports {
		if pos := node.End(); pos > furthestPos {
			furthestPos = pos
		}
	}
	if furthestPos < token.Pos(len(b)) {
		furthestPos++

		// Avoid wrong output on windows-encoded files
		if b[furthestPos-2] == '\r' && b[furthestPos-1] == '\n' && furthestPos < token.Pos(len(b)) {
			furthestPos++
		}
	}
	return b[furthestPos:]
}
361758
func (d dataGeocoder) Geocode(address string) (*geo.Location, error) {
	addr := geo.Address{
		FormattedAddress: address,
	}
	if l, ok := d.AddressToLocation[addr]; ok {
		return &l, nil
	}

	return nil, nil
}
394912
func TypeCode(g Generator, spec compile.TypeSpec) string {
	wire := g.Import("go.uber.org/thriftrw/wire")
	spec = compile.RootTypeSpec(spec)

	switch spec.(type) {
	case *compile.BoolSpec:
		return fmt.Sprintf("%s.TBool", wire)
	case *compile.I8Spec:
		return fmt.Sprintf("%s.TI8", wire)
	case *compile.I16Spec:
		return fmt.Sprintf("%s.TI16", wire)
	case *compile.I32Spec:
		return fmt.Sprintf("%s.TI32", wire)
	case *compile.I64Spec:
		return fmt.Sprintf("%s.TI64", wire)
	case *compile.DoubleSpec:
		return fmt.Sprintf("%s.TDouble", wire)
	case *compile.StringSpec, *compile.BinarySpec:
		return fmt.Sprintf("%s.TBinary", wire)
	case *compile.MapSpec:
		return fmt.Sprintf("%s.TMap", wire)
	case *compile.ListSpec:
		return fmt.Sprintf("%s.TList", wire)
	case *compile.SetSpec:
		return fmt.Sprintf("%s.TSet", wire)
	case *compile.EnumSpec:
		return fmt.Sprintf("%s.TI32", wire)
	case *compile.StructSpec:
		return fmt.Sprintf("%s.TStruct", wire)
	default:
		panic(fmt.Sprintf("unknown type spec %v (type %T)", spec, spec))
	}
}
392725
func Code(err error) codes.Code {
	if code, ok := Tag.In(err); ok {
		return code
	}
	// TODO(nodir): use status.FromError
	return grpc.Code(errors.Unwrap(err))
}
1134154
func (c *Client) LanguageCodes() ([]*models.LanguageCode, error) {
	var err error
	var result []*models.LanguageCode

	data, err := httpGet(geonamesURL + languageCodesURL)
	if err != nil {
		return nil, err
	}

	parse(data, 1, func(raw [][]byte) bool {
		if len(raw) != 4 {
			return true
		}

		result = append(result, &models.LanguageCode{
			Iso3: string(raw[0]),
			Iso2: string(raw[1]),
			Iso:  string(raw[2]),
			Name: string(raw[3]),
		})

		return true
	})

	return result, nil
}
82661
func (s *ImageStateChangeReason) SetCode(v string) *ImageStateChangeReason {
	s.Code = &v
	return s
}
1247285
func (a *API) importsGoCode() string {
	if len(a.imports) == 0 {
		return ""
	}

	corePkgs, extPkgs := []string{}, []string{}
	for i := range a.imports {
		if strings.Contains(i, ".") {
			extPkgs = append(extPkgs, i)
		} else {
			corePkgs = append(corePkgs, i)
		}
	}
	sort.Strings(corePkgs)
	sort.Strings(extPkgs)

	code := "import (\n"
	for _, i := range corePkgs {
		code += fmt.Sprintf("\t%q\n", i)
	}
	if len(corePkgs) > 0 {
		code += "\n"
	}
	for _, i := range extPkgs {
		code += fmt.Sprintf("\t%q\n", i)
	}
	code += ")\n\n"
	return code
}
1164119
func (info *ImageInfoType) GobEncode() (buf []byte, err error) {
	fields := []interface{}{info.data, info.smask, info.n, info.w, info.h, info.cs,
		info.pal, info.bpc, info.f, info.dp, info.trns, info.scale, info.dpi}
	w := new(bytes.Buffer)
	encoder := gob.NewEncoder(w)
	for j := 0; j < len(fields) && err == nil; j++ {
		err = encoder.Encode(fields[j])
	}
	if err == nil {
		buf = w.Bytes()
	}
	return
}
983331
func GenerateCode(secret string, counter uint64) (string, error) {
	return GenerateCodeCustom(secret, counter, ValidateOpts{
		Digits:    otp.DigitsSix,
		Algorithm: otp.AlgorithmSHA1,
	})
}
468683
func GoFmt(buf string) string {
	formatted, err := format.Source([]byte(buf))
	if err != nil {
		panic(fmt.Errorf("%s\nOriginal code:\n%s", err.Error(), buf))
	}
	return string(formatted)
}
281429
func (n *node) GobDecode(buf []byte) error {
	r := bytes.NewBuffer(buf)
	decoder := gob.NewDecoder(r)
	if err := decoder.Decode(&n.nodes); err != nil {
		return err
	}
	if err := decoder.Decode(&n.keys); err != nil {
		return err
	}
	if err := decoder.Decode(&n.keysBytes); err != nil {
		return err
	}
	return decoder.Decode(&n.Node)
}
612586
func (h *Item) Code(code string) *Item {
	h.code = code
	h.codeSet = true
	return h
}
214165
func urlDecode(hdrVal string) string {
	if valUnescaped, errUnescaping := url.QueryUnescape(hdrVal); errUnescaping == nil {
		hdrVal = valUnescaped
	}
	return hdrVal
}