// The following code is intended to be called by the program generated by ../reflect.go.
323390
func InterfaceFromInterfaceType(it reflect.Type) (*Interface, error) {
	if it.Kind() != reflect.Interface {
		return nil, fmt.Errorf("%v is not an interface", it)
	}
	intf := &Interface{}

	for i := 0; i < it.NumMethod(); i++ {
		mt := it.Method(i)
		// TODO: need to skip unexported methods? or just raise an error?
		m := &Method{
			Name: mt.Name,
		}

		var err error
		m.In, m.Variadic, m.Out, err = funcArgsFromType(mt.Type)
		if err != nil {
			return nil, err
		}

		intf.Methods = append(intf.Methods, m)
	}

	return intf, nil
}
125770
func indirect(v reflect.Value) reflect.Value {
loop:
	for {
		switch v.Kind() {
		case reflect.Interface, reflect.Ptr:
			v = v.Elem()
		default:
			break loop
		}
	}
	return v
}
552
func (p provider) Provide(g Graph) reflect.Value {
	fnType := reflect.TypeOf(p.constructor)

	argCount := fnType.NumIn()
	if fnType.IsVariadic() {
		argCount = len(p.argPtrs)
	}

	args := make([]reflect.Value, argCount, argCount)
	var inType reflect.Type
	for i := 0; i < argCount; i++ {
		arg := g.Resolve(p.argPtrs[i])
		argType := arg.Type()

		if i < fnType.NumIn() {
			inType = fnType.In(i)
		} else {
			inType = fnType.In(fnType.NumIn() - 1)
		}

		if inType.Kind() == reflect.Slice {
			inType = inType.Elem()
		}

		if !argType.AssignableTo(inType) {
			if !argType.ConvertibleTo(inType) {
				panic(fmt.Sprintf(
					"arg %d of type %q cannot be assigned or converted to type %q for provider constructor (%s)",
					i, argType, inType, p.constructor,
				))
			}
			arg = arg.Convert(inType)
		}
		args[i] = arg
	}

	return reflect.ValueOf(p.constructor).Call(args)[0]
}
765735
func main() {
	var (
		settings         []Option
		settingsTemplate = createTemplate("templates/query_params.go.tmpl")
		filepath         = "../../search/query_params.go"
	)

	for _, opt := range options {
		if isSearch(opt.Kind) {
			settings = append(settings, opt)
		}
	}

	generateFile(settingsTemplate, settings, filepath)
}
27084
func (x *genRunner) enc(varname string, t reflect.Type) {
	rtid := rt2id(t)
	ti2 := x.ti.get(rtid, t)
	// We call CodecEncodeSelf if one of the following are honored:
	//   - the type already implements Selfer, call that
	//   - the type has a Selfer implementation just created, use that
	//   - the type is in the list of the ones we will generate for, but it is not currently being generated

	mi := x.varsfx()
	// tptr := reflect.PtrTo(t)
	tk := t.Kind()
	if x.checkForSelfer(t, varname) {
		if tk == reflect.Array || (tk == reflect.Struct && rtid != timeTypId) { // varname is of type *T
			// if tptr.Implements(selferTyp) || t.Implements(selferTyp) {
			if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) {
				x.line(varname + ".CodecEncodeSelf(e)")
				return
			}
		} else { // varname is of type T
			if ti2.cs { // t.Implements(selferTyp) {
				x.line(varname + ".CodecEncodeSelf(e)")
				return
			} else if ti2.csp { // tptr.Implements(selferTyp) {
				x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname)
				x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi)
				return
			}
		}

		if _, ok := x.te[rtid]; ok {
			x.line(varname + ".CodecEncodeSelf(e)")
			return
		}
	}

	inlist := false
	for _, t0 := range x.t {
		if t == t0 {
			inlist = true
			if x.checkForSelfer(t, varname) {
				x.line(varname + ".CodecEncodeSelf(e)")
				return
			}
			break
		}
	}

	var rtidAdded bool
	if t == x.tc {
		x.te[rtid] = true
		rtidAdded = true
	}

	// check if
	//   - type is time.Time, RawExt, Raw
	//   - the type implements (Text|JSON|Binary)(Unm|M)arshal

	x.line("if false {")           //start if block
	defer func() { x.line("}") }() //end if block

	if t == timeTyp {
		x.linef("} else if !z.EncBasicHandle().TimeNotBuiltin { r.EncodeTime(%s)", varname)
		// return
	}
	if t == rawTyp {
		x.linef("} else { z.EncRaw(%s)", varname)
		return
	}
	if t == rawExtTyp {
		x.linef("} else { r.EncodeRawExt(%s, e)", varname)
		return
	}
	// only check for extensions if the type is named, and has a packagePath.
	var arrayOrStruct = tk == reflect.Array || tk == reflect.Struct // meaning varname if of type *T
	if !x.nx && genImportPath(t) != "" && t.Name() != "" {
		yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi)
		x.linef("} else if %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.EncExtension(%s, %s) ", yy, varname, yy, varname, yy)
	}
	if arrayOrStruct { // varname is of type *T
		if ti2.bm || ti2.bmp { // t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) {
			x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(%v) ", varname)
		}
		if ti2.jm || ti2.jmp { // t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) {
			x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", varname)
		} else if ti2.tm || ti2.tmp { // t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) {
			x.linef("} else if !z.EncBinary() { z.EncTextMarshal(%v) ", varname)
		}
	} else { // varname is of type T
		if ti2.bm { // t.Implements(binaryMarshalerTyp) {
			x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(%v) ", varname)
		} else if ti2.bmp { // tptr.Implements(binaryMarshalerTyp) {
			x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(&%v) ", varname)
		}
		if ti2.jm { // t.Implements(jsonMarshalerTyp) {
			x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", varname)
		} else if ti2.jmp { // tptr.Implements(jsonMarshalerTyp) {
			x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", varname)
		} else if ti2.tm { // t.Implements(textMarshalerTyp) {
			x.linef("} else if !z.EncBinary() { z.EncTextMarshal(%v) ", varname)
		} else if ti2.tmp { // tptr.Implements(textMarshalerTyp) {
			x.linef("} else if !z.EncBinary() { z.EncTextMarshal(&%v) ", varname)
		}
	}
	x.line("} else {")

	switch t.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		x.line("r.EncodeInt(int64(" + varname + "))")
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		x.line("r.EncodeUint(uint64(" + varname + "))")
	case reflect.Float32:
		x.line("r.EncodeFloat32(float32(" + varname + "))")
	case reflect.Float64:
		x.line("r.EncodeFloat64(float64(" + varname + "))")
	case reflect.Bool:
		x.line("r.EncodeBool(bool(" + varname + "))")
	case reflect.String:
		x.linef("if z.EncBasicHandle().StringToRaw { r.EncodeStringBytesRaw(z.BytesView(string(%s))) } else { r.EncodeStringEnc(codecSelferCcUTF8%s, string(%s)) }", varname, x.xs, varname)
	case reflect.Chan:
		x.xtraSM(varname, t, true, false)
		// x.encListFallback(varname, rtid, t)
	case reflect.Array:
		x.xtraSM(varname, t, true, true)
	case reflect.Slice:
		// if nil, call dedicated function
		// if a []uint8, call dedicated function
		// if a known fastpath slice, call dedicated function
		// else write encode function in-line.
		// - if elements are primitives or Selfers, call dedicated function on each member.
		// - else call Encoder.encode(XXX) on it.
		if rtid == uint8SliceTypId {
			x.line("r.EncodeStringBytesRaw([]byte(" + varname + "))")
		} else if fastpathAV.index(rtid) != -1 {
			g := x.newGenV(t)
			x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
		} else {
			x.xtraSM(varname, t, true, false)
			// x.encListFallback(varname, rtid, t)
		}
	case reflect.Map:
		// if nil, call dedicated function
		// if a known fastpath map, call dedicated function
		// else write encode function in-line.
		// - if elements are primitives or Selfers, call dedicated function on each member.
		// - else call Encoder.encode(XXX) on it.
		// x.line("if " + varname + " == nil { \nr.EncodeNil()\n } else { ")
		if fastpathAV.index(rtid) != -1 {
			g := x.newGenV(t)
			x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
		} else {
			x.xtraSM(varname, t, true, false)
			// x.encMapFallback(varname, rtid, t)
		}
	case reflect.Struct:
		if !inlist {
			delete(x.te, rtid)
			x.line("z.EncFallback(" + varname + ")")
			break
		}
		x.encStruct(varname, rtid, t)
	default:
		if rtidAdded {
			delete(x.te, rtid)
		}
		x.line("z.EncFallback(" + varname + ")")
	}
}
498061
func main() {
	opts := &Options{}
	_, err := flags.Parse(opts)
	if err != nil {
		log.Fatal(err)
	}

	err = config.LoadDotEnvSkipEmpty(os.Getenv("ENV_PATH"), "./.env")
	if err != nil {
		log.Fatal(err)
	}

	apiClient, err := Initialize()
	if err != nil {
		log.Fatal(err)
	}

	req := rc.ExtensionUpdateRequest{
		Contact: rc.ContactInfoUpdateRequest{
			FirstName: opts.FirstName,
			LastName:  opts.LastName}}

	info, resp, err := apiClient.UserSettingsApi.UpdateExtension(
		context.Background(), "~", "~", req)
	if err != nil {
		log.Fatal(err)
	} else if resp.StatusCode >= 300 {
		log.Fatal(fmt.Sprintf("API Status %v", resp.StatusCode))
	}

	fmt.Printf("Status: %v\n", resp.StatusCode)

	fmtutil.PrintJSON(info)

	fmt.Println("DONE")
}
209396
func goHintCallback(_name, _oldValue, _newValue *C.char) {
	name := C.GoString(_name)
	oldValue := C.GoString(_oldValue)
	newValue := C.GoString(_newValue)
	if cb, ok := hintCallbacks[name]; ok {
		cb.callback(cb.data, name, oldValue, newValue)
	}
}
1282845
func main() {
	var (
		extractLiteralTemplate = createTemplate("templates/extract/literal.go.tmpl")
		extractMapTemplate     = createTemplate("templates/extract/map_string_string.go.tmpl")
	)

	for _, opt := range options {
		filename := generateFilename(opt.Name)
		filepath := "../opt/" + filename

		if shouldBeGenerated(filepath) {
			switch opt.DefaultValue.(type) {
			case nil, bool, int, string, []string, map[string][]string:
				generateFile(extractLiteralTemplate, opt.Name, filepath)
			case map[string]string:
				generateFile(extractMapTemplate, opt.Name, filepath)
			default:
				fmt.Printf("cannot generate extract option file for %s: unhandled type %#v", opt.Name, opt.DefaultValue)
				os.Exit(1)
			}
		}
	}
}
505289
func main() {
	args := map[string]string{}
	gp := geopattern.Generate(args)
	fmt.Println(gp)
}
233090
func main () {
    d := GOnetstat.Tcp()

    // Marshal in prety print way
    output, err := json.MarshalIndent(d, "", "    ")
    if err != nil {
        fmt.Println(err)
    }

    fmt.Println(string(output))
}
646646
func (err *gojoyentError) code() Code {
	if err.errcode != UnknownErrorError {
		return err.errcode
	}
	if e, ok := err.cause.(*gojoyentError); ok {
		return e.code()
	}
	return UnknownErrorError
}
304890
func (c *Context) Code(code int) (err error) {
	c.response.WriteHeader(code)
	return
}
1086404
func (scope *Scope) callMethod(methodName string, reflectValue reflect.Value) {
	// Only get address from non-pointer
	if reflectValue.CanAddr() && reflectValue.Kind() != reflect.Ptr {
		reflectValue = reflectValue.Addr()
	}

	if methodValue := reflectValue.MethodByName(methodName); methodValue.IsValid() {
		switch method := methodValue.Interface().(type) {
		case func():
			method()
		case func(*Scope):
			method(scope)
		case func(*DB):
			newDB := scope.NewDB()
			method(newDB)
			scope.Err(newDB.Error)
		case func() error:
			scope.Err(method())
		case func(*Scope) error:
			scope.Err(method(scope))
		case func(*DB) error:
			newDB := scope.NewDB()
			scope.Err(method(newDB))
			scope.Err(newDB.Error)
		default:
			scope.Err(fmt.Errorf("unsupported function %v", methodName))
		}
	}
}
1291749
func (client *BaseClient) Go(
	name string,
	args []reflect.Value,
	settings *InvokeSettings,
	callback Callback) {
	go func() {
		defer client.fireErrorEvent(name, nil)
		callback(client.Invoke(name, args, settings))
	}()
}
650907
func init() {
	historicUsage = &Usage{}
	var cycles uint64
	go func() {
		for {
			time.Sleep(memUsageMeasureInterval)
			currUsage := GetUsage()
			currSum := cycles * historicUsage.Mem
			cycles = cycles + 1
			historicUsage.Mem = (currSum + currUsage.Mem) / cycles
		}
	}()
}
121159
func (g *Group) Go(fn func() error) {
	g.wg.Add(1)
	go func() {
		err := fn()
		if err != nil {
			g.mu.Lock()
			g.errs = append(g.errs, err)
			g.mu.Unlock()
		}
		g.wg.Done()
	}()
}
1082778
func ReflectValue(valueType string, value interface{}) (reflect.Value, error) {
	if strings.HasPrefix(valueType, "[]") {
		return reflectValues(valueType, value)
	}

	return reflectValue(valueType, value)
}