// ToGokit turns a golib logger into a go-kit logger
345479
func ToGokit(logger Logger) ErrorLogger {
	if root, ok := logger.(*ErrorLogLogger); ok {
		return root.RootLogger
	}
	return &LoggerKit{
		LogTo: logger,
	}
}
430167
func (i *IntRule) GobDecode(buf []byte) error {
	r := bytes.NewBuffer(buf)
	decoder := gob.NewDecoder(r)
	if err := decoder.Decode(&i.key); err != nil {
		return err
	}
	if err := decoder.Decode(&i.required); err != nil {
		return err
	}
	var is_default_set bool
	decoder.Decode(&is_default_set)
	if is_default_set {
		return decoder.Decode(&i.default_)
	}
	var is_minimum_set bool
	decoder.Decode(&is_minimum_set)
	if is_minimum_set {
		if err := decoder.Decode(&i.minimum); err != nil {
			return err
		}
	}
	var is_maximum_set bool
	decoder.Decode(&is_maximum_set)
	if is_maximum_set {
		if err := decoder.Decode(&i.maximum); err != nil {
			return err
		}
	}
	return nil
}
372395
func (toolkit GoToolkit) Bootstrap() error {
	if toolkit.IsToolAvailableInPATH() {
		return nil
	}

	pthWithGoBins := configs.GeneratePATHEnvString(os.Getenv("PATH"), goToolkitBinsPath())
	if err := os.Setenv("PATH", pthWithGoBins); err != nil {
		return fmt.Errorf("Failed to set PATH to include the Go toolkit bins, error: %s", err)
	}

	if err := os.Setenv("GOROOT", goToolkitInstallRootPath()); err != nil {
		return fmt.Errorf("Failed to set GOROOT to Go toolkit root, error: %s", err)
	}

	return nil
}
603130
func (a *API) APIGoCode() string {
	a.resetImports()
	a.AddSDKImport("aws")
	a.AddSDKImport("aws/awsutil")
	a.AddSDKImport("aws/request")

	var buf bytes.Buffer
	err := tplAPI.Execute(&buf, a)
	if err != nil {
		panic(err)
	}

	code := a.importsGoCode() + strings.TrimSpace(buf.String())
	return code
}
1252576
func (p PrintResult) IsOK() bool {
	return p.Error == nil && len(p.Contents) > 0
}
767312
func (client *TPMClient) GenerateAIK() (aikpub []byte, aikblob []byte, err error) {
	var aikData AikResponse

	aikresp, err := client.post(GenerateAikURL, nil)
	if err != nil {
		return nil, nil, fmt.Errorf("Can't generate AIK: %s", err)
	}
	defer aikresp.Body.Close()
	body, err := ioutil.ReadAll(aikresp.Body)
	if err != nil {
		return nil, nil, fmt.Errorf("Can't read AIK response: %s", err)
	}

	err = json.Unmarshal(body, &aikData)
	if err != nil {
		return nil, nil, fmt.Errorf("Can't parse AIK response: %s (%s)", err, body)
	}

	aikpub = aikData.AIKPub
	aikblob = aikData.AIKBlob

	return aikpub, aikblob, nil
}
584653
func (s *InstanceHealthSummary) SetOk(v int64) *InstanceHealthSummary {
	s.Ok = &v
	return s
}
238691
func (w *Waiter) GoCode() string {
	var buf bytes.Buffer
	if err := waiterTmpls.ExecuteTemplate(&buf, "waiter", w); err != nil {
		panic(err)
	}

	return buf.String()
}
191932
func (s *Application) ModuleOk(args ...string) (app *Module, ok bool) {
	name := s.RootModuleName
	if len(args) > 0 {
		name = args[0]
	}
	app, ok = s.moduleNames[name]
	return
}
617404
func goList(params, pkgs []string) []string {
	templateParams := make([]string, 0, len(params))
	for _, p := range params {
		templateParams = append(templateParams, "{{."+p+"}}")
	}
	return append([]string{
		"go",
		"list",
		"-f", strings.Join(templateParams, goSeparator),
	}, pkgs...)
}
798140
func _go_glib_callback(cbi *C.callback_info) {
	value, found := callback_contexts.Get(int(cbi.func_no))
	if !found {
		return
	}
	context := value.(*CallbackContext)
	t := context.f.Type()
	fargs := make([]reflect.Value, t.NumIn())
	if len(fargs) > 0 {
		fargs[0] = reflect.ValueOf(context)
	}
	ret := context.f.Call(fargs)
	if len(ret) > 0 {
		value := ret[0].Interface()
		switch value.(type) {
		case bool:
			bval := gbool(value.(bool))
			cbi.ret = unsafe.Pointer(&bval)
		case byte:
			bval := C.gchar(value.(byte))
			cbi.ret = unsafe.Pointer(&bval)
		case int:
			ival := C.int(value.(int))
			cbi.ret = unsafe.Pointer(&ival)
		case uint:
			uval := C.guint(value.(uint))
			cbi.ret = unsafe.Pointer(&uval)
		case float32:
			f32val := C.gfloat(value.(float32))
			cbi.ret = unsafe.Pointer(&f32val)
		case float64:
			f64val := C.gfloat(value.(float64))
			cbi.ret = unsafe.Pointer(&f64val)
		case string:
			cbi.ret = unsafe.Pointer(C.CString(value.(string)))
		default:
			if pv, ok := value.(*[0]uint8); ok {
				cbi.ret = unsafe.Pointer(pv)
			} else {
				av := reflect.ValueOf(value)
				if av.Kind() == reflect.Ptr {
					cbi.ret = unsafe.Pointer(av.Pointer())
				} else if av.CanAddr() {
					cbi.ret = unsafe.Pointer(av.UnsafeAddr())
				} else {
					cbi.ret = unsafe.Pointer(&value)
				}
			}
		}
	}
}
1149953
func (k *Kite) KiteKey() string {
	k.configMu.RLock()
	defer k.configMu.RUnlock()

	return k.Config.KiteKey
}
796771
func InitLogger(logLevel int) {
	SetLogLevel(logLevel)
	if logLevel <= LDebug {
		log.SetFlags(log.LstdFlags | log.Lshortfile)
	}
}
539324
func GeneratePK(bits int) (key *PrivateKey, err error) {
	var rsaKey *rsa.PrivateKey
	rsaKey, err = rsa.GenerateKey(rand.Reader, bits)
	if err == nil {
		key = &PrivateKey{rsaKey: rsaKey}
	}
	return
}
875085
func (s *StableBloomFilter) GobDecode(data []byte) error {
	buf := bytes.NewBuffer(data)
	_, err := s.ReadFrom(buf)
	return err
}
1164436
func LoggerMiddleware(next http.Handler) http.Handler {
	fn := func(w http.ResponseWriter, r *http.Request) {
		_, ctx := LoggerCtx(r)
		next.ServeHTTP(w, r.WithContext(ctx))
	}

	return http.HandlerFunc(fn)
}
469304
func ToGoOSArch(appcOs string, appcArch string) (goOs string, goArch string, goArchFlavor string, e error) {
	tabularGoToAppc := map[appcArchTuple]goArchTuple{
		// {"linux", "aarch64_be"}: nil,
		// {"linux", "armv7b"}: nil,
		{"linux", "aarch64"}: {"linux", "arm64", ""},
		{"linux", "amd64"}:   {"linux", "amd64", ""},
		{"linux", "armv6l"}:  {"linux", "arm", "6"},
		{"linux", "armv7l"}:  {"linux", "arm", "7"},
		{"linux", "i386"}:    {"linux", "386", ""},
		{"linux", "ppc64"}:   {"linux", "ppc64", ""},
		{"linux", "ppc64le"}: {"linux", "ppc64le", ""},
		{"linux", "s390x"}:   {"linux", "s390x", ""},

		{"freebsd", "amd64"}: {"freebsd", "amd64", ""},
		{"freebsd", "arm"}:   {"freebsd", "arm", "6"},
		{"freebsd", "386"}:   {"freebsd", "i386", ""},

		{"darwin", "amd64"}: {"darwin", "x86_64", ""},
		{"darwin", "386"}:   {"darwin", "i386", ""},
	}

	archTuple, ok := tabularGoToAppc[appcArchTuple{appcOs, appcArch}]
	if !ok {
		return "", "", "", fmt.Errorf("unknown arch tuple: %q - %q", appcOs, appcArch)
	}
	return archTuple.goOs, archTuple.goArch, archTuple.goArchFlavor, nil
}