//++ TODO check for nil pointers in all these methods. When so: return os.PathError with Err: os.ErrInvalid
556053
func (vf *virtualFile) close() error {
	if vf.closed {
		return &os.PathError{
			Op:   "close",
			Path: vf.EmbeddedFile.Filename,
			Err:  errors.New("already closed"),
		}
	}
	vf.EmbeddedFile = nil
	vf.closed = true
	return nil
}
766640
func init() {
	flag.Int64VarP(&number, "number", "n", 10, "how many lines to return")
	flag.BoolVarP(&follow, "follow", "f", false, "follow file changes")
	flag.BoolVarP(&reopen, "reopen", "F", false, "implies -f and re-opens moved / truncated files")
}
446460
func Init(goPath string, goRoot string) {

	var goPathList []string
	var goRootList []string
	var defaultgoPathList []string
	var defaultgoRootList []string
	pathSeperator := ":"
	// Add all possible GOPATH paths into trimStrings
	// Split GOPATH depending on the OS type
	if runtime.GOOS == "windows" {
		pathSeperator = ";"
	}

	goPathList = strings.Split(goPath, pathSeperator)
	goRootList = strings.Split(goRoot, pathSeperator)
	defaultgoPathList = strings.Split(build.Default.GOPATH, pathSeperator)
	defaultgoRootList = strings.Split(build.Default.GOROOT, pathSeperator)

	// Add trim string "{GOROOT}/src/" into trimStrings
	trimStrings = []string{filepath.Join(runtime.GOROOT(), "src") + string(filepath.Separator)}

	// Add all possible path from GOPATH=path1:path2...:pathN
	// as "{path#}/src/" into trimStrings
	for _, goPathString := range goPathList {
		trimStrings = append(trimStrings, filepath.Join(goPathString, "src")+string(filepath.Separator))
	}

	for _, goRootString := range goRootList {
		trimStrings = append(trimStrings, filepath.Join(goRootString, "src")+string(filepath.Separator))
	}

	for _, defaultgoPathString := range defaultgoPathList {
		trimStrings = append(trimStrings, filepath.Join(defaultgoPathString, "src")+string(filepath.Separator))
	}

	for _, defaultgoRootString := range defaultgoRootList {
		trimStrings = append(trimStrings, filepath.Join(defaultgoRootString, "src")+string(filepath.Separator))
	}

	// Remove duplicate entries.
	trimStrings = uniqueEntries(trimStrings)

	// Add "github.com/minio/minio" as the last to cover
	// paths like "{GOROOT}/src/github.com/minio/minio"
	// and "{GOPATH}/src/github.com/minio/minio"
	trimStrings = append(trimStrings, filepath.Join("github.com", "minio", "minio")+string(filepath.Separator))

	loggerHighwayHasher, _ = highwayhash.New(magicHighwayHash256Key) // New will never return error since key is 256 bit
}
548988
func errPanic(err error, line int) {
	panic(fmt.Errorf("Parse error on line %d:\n%s", line, err))
}
447304
func argError(exitCode int, msg string, args ...interface{}) {
	fmt.Fprintf(os.Stderr, msg, args...)
	fmt.Fprintln(os.Stderr)
	usage()
	exit(exitCode)
}
435368
func (pm *pointerMap) getAllAndReusedPointers(v reflect.Value) {
	if v.Kind() == reflect.Invalid {
		return
	}
	if isPointerValue(v) && v.Pointer() != 0 { // pointer is 0 for unexported fields
		reused := pm.addPointer(v.Pointer())
		if reused {
			// No use descending inside this value, since it have been seen before and all its descendants
			// have been considered
			return
		}
	}

	// Now descend into any children of this value
	switch v.Kind() {
	case reflect.Slice, reflect.Array:
		numEntries := v.Len()
		for i := 0; i < numEntries; i++ {
			pm.getAllAndReusedPointers(v.Index(i))
		}

	case reflect.Interface:
		pm.getAllAndReusedPointers(v.Elem())

	case reflect.Ptr:
		pm.getAllAndReusedPointers(v.Elem())

	case reflect.Map:
		for _, key := range v.MapKeys() {
			pm.getAllAndReusedPointers(v.MapIndex(key))
		}

	case reflect.Struct:
		numFields := v.NumField()
		for i := 0; i < numFields; i++ {
			pm.getAllAndReusedPointers(v.Field(i))
		}
	}
}
632793
func (m Methods) ToMarshalJSON(receiver, pkgPath string, excludes ...string) (string, []string) {
	var sb strings.Builder

	r := receiverShort(receiver)
	what := firstToUpper(trimAsterisk(receiver))
	pgkName := path.Base(pkgPath)

	fmt.Fprintf(&sb, "func Marshal%sToJSON(%s %s) ([]byte, error) {\n", what, r, receiver)

	var methods Methods
	var excludeRes = make([]*regexp.Regexp, len(excludes))

	for i, exclude := range excludes {
		excludeRes[i] = regexp.MustCompile(exclude)
	}

	for _, method := range m {
		// Exclude methods with arguments and incompatible return values
		if len(method.In) > 0 || len(method.Out) == 0 || len(method.Out) > 2 {
			continue
		}

		if len(method.Out) == 2 {
			if method.Out[1] != "error" {
				continue
			}
		}

		for _, re := range excludeRes {
			if re.MatchString(method.Name) {
				continue
			}
		}

		methods = append(methods, method)
	}

	for _, method := range methods {
		varn := varName(method.Name)
		if len(method.Out) == 1 {
			fmt.Fprintf(&sb, "\t%s := %s.%s()\n", varn, r, method.Name)
		} else {
			fmt.Fprintf(&sb, "\t%s, err := %s.%s()\n", varn, r, method.Name)
			fmt.Fprint(&sb, "\tif err != nil {\n\t\treturn nil, err\n\t}\n")
		}
	}

	fmt.Fprint(&sb, "\n\ts := struct {\n")

	for _, method := range methods {
		fmt.Fprintf(&sb, "\t\t%s %s\n", method.Name, typeName(method.Out[0], pgkName))
	}

	fmt.Fprint(&sb, "\n\t}{\n")

	for _, method := range methods {
		varn := varName(method.Name)
		fmt.Fprintf(&sb, "\t\t%s: %s,\n", method.Name, varn)
	}

	fmt.Fprint(&sb, "\n\t}\n\n")
	fmt.Fprint(&sb, "\treturn json.Marshal(&s)\n}")

	pkgImports := append(methods.Imports(), "encoding/json")

	if pkgPath != "" {
		// Exclude self
		for i, pkgImp := range pkgImports {
			if pkgImp == pkgPath {
				pkgImports = append(pkgImports[:i], pkgImports[i+1:]...)
			}
		}
	}

	return sb.String(), pkgImports

}
412943
func init() {
	var err error
	fm := template.FuncMap{
		"tabs":     Tabs,
		"slice":    toSlice,
		"oneof":    oneof,
		"constant": constant,
		"goifyAtt": GoifyAtt,
		"add":      Add,
	}
	if enumValT, err = template.New("enum").Funcs(fm).Parse(enumValTmpl); err != nil {
		panic(err)
	}
	if formatValT, err = template.New("format").Funcs(fm).Parse(formatValTmpl); err != nil {
		panic(err)
	}
	if patternValT, err = template.New("pattern").Funcs(fm).Parse(patternValTmpl); err != nil {
		panic(err)
	}
	if minMaxValT, err = template.New("minMax").Funcs(fm).Parse(minMaxValTmpl); err != nil {
		panic(err)
	}
	if lengthValT, err = template.New("length").Funcs(fm).Parse(lengthValTmpl); err != nil {
		panic(err)
	}
	if requiredValT, err = template.New("required").Funcs(fm).Parse(requiredValTmpl); err != nil {
		panic(err)
	}
}
23773
func (p pointer) getPointerSlice() []pointer {
	if p.v.IsNil() {
		return nil
	}
	n := p.v.Elem().Len()
	s := make([]pointer, n)
	for i := 0; i < n; i++ {
		s[i] = pointer{v: p.v.Elem().Index(i)}
	}
	return s
}
961029
func FindFilesInDir(dirPath string, isValidFile func(path string) bool, shouldSkip func(path string, f os.FileInfo) bool) []string {
	files := []string{}
	filepath.Walk(dirPath, func(path string, f os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if shouldSkip(path, f) {
			return filepath.SkipDir
		}
		if !f.IsDir() && isValidFile(path) {
			files = append(files, path)
		}
		return nil
	})
	return files
}
367834
func (p *Path) Or(path *Path) *Path {
	np := p.clone()
	np.stack = append(np.stack, orMorphism(path))
	return np
}
186404
func (e *NodeRedeclarationError) Error() string {
	// TODO(vadimsh): Improve error messages.
	return fmt.Sprintf("%s is redeclared, previous declaration:\n%s", e.Previous, e.Previous.Trace)
}
31730
func (e *ErrorsTotalMap) retrievePointerFor(err HTTPError) *uint64 {
	serr := simplifyHTTPError(err)
	e.lock.RLock()
	ptr, ok := e.counter[serr]
	e.lock.RUnlock()
	if ok {
		return ptr
	}

	// For pointer creation, a write-lock is required
	e.lock.Lock()
	// We ensure that the pointer wasn't created in the meantime
	if ptr, ok = e.counter[serr]; !ok {
		ptr = new(uint64)
		e.counter[serr] = ptr
	}
	e.lock.Unlock()

	return ptr
}
1099367
func main() {
	data := map[string]int{}

	for i := 0; i < 100; i++ {
		err := retro.DoWithRetry(func() error {
			return storeInt(data, i)
		})
		if err != nil {
			fmt.Printf("FATAL: Failed to store %d: %s\n", i, err.Error())
			os.Exit(1)
		}
	}

}
1001407
func goErrorHandler(code C.int, reason *C.char) {
	reasonHeader := reflect.StringHeader{
		Data: uintptr(unsafe.Pointer(reason)),
		Len:  int(C.strlen(reason)),
	}
	reasonString := (*string)(unsafe.Pointer(&reasonHeader))
	Log.Printf("%s -- %s", codeToString(int(code)), *reasonString)
}
1351693
func (ref Ref) Ptr() (string, error) {
	parts := make([]string, 0, len(ref)-1)
	for _, term := range ref[1:] {
		if str, ok := term.Value.(String); ok {
			parts = append(parts, url.PathEscape(string(str)))
		} else {
			return "", fmt.Errorf("invalid path value type")
		}
	}
	return strings.Join(parts, "/"), nil
}
151195
func init() {
	for _, v := range os.Args {
		if v == "--version" || v == "-version" {
			fmt.Println(VersionString())
			os.Exit(0)
		}
	}
}