// try to set root import path based on target dir
// - do nothing if user specify import path
// - if target dir is under GOPATH, set it to the target dir
179775
func setRootImportPath(importPath, targetDir string) string {
	// use import path if not empty
	if len(importPath) > 0 {
		return importPath
	}

	// get GOPATH dir
	gopath, err := filepath.Abs(os.Getenv("GOPATH"))
	if err != nil {
		return ""
	}
	gopath = filepath.Join(gopath, "src")

	// get absolute target dir
	absTargetDir, err := filepath.Abs(targetDir)
	if err != nil {
		panic("invalid targetDir:" + err.Error())
	}

	// panic if user doesn't specify import path and target dir
	// not under GOPATH.
	if !strings.HasPrefix(absTargetDir, gopath) {
		panic("please specify '--import-path' or set '--dir' under your GOPATH")
	}

	// set import path
	newImportPath, err := filepath.Rel(gopath, absTargetDir)
	if err != nil {
		panic("failed to set import path automatically:" + err.Error())
	}

	// re-join because otherwise windows will use `\`
	return path.Join(strings.Split(newImportPath, string(filepath.Separator))...)
}
1059387
func (s *Role) SetPath(v string) *Role {
	s.Path = &v
	return s
}
635277
func (p *Importer) absPath(path string) (string, error) {
	// TODO(gri) This should be using p.ctxt.AbsPath which doesn't
	// exist but probably should. See also issue #14282.
	return filepath.Abs(path)
}
310567
func (r *Request) SetPath(path string) {
	if r.URL == nil {
		r.URL = &url.URL{}
	}
	r.URL.Path = path
}
853360
func (u *Update) Target(path string) *Update {
	u.TargetPath = path
	return u
}
192098
func (s *S3Target) SetPath(v string) *S3Target {
	s.Path = &v
	return s
}
513628
func (s *Disk) SetDiskPath(v string) *Disk {
	s.DiskPath = &v
	return s
}
95546
func Init() {
	// Root path is automatically determined from the calling function's source file location.
	// Catch the calling function's source file path.
	_, file, _, _ := runtime.Caller(1)
	// Save the directory alone.
	rootPath = filepath.Dir(file)

	appInfo = make(map[string]string)
}
890373
func (s *CreateUserInput) SetPath(v string) *CreateUserInput {
	s.Path = &v
	return s
}
309377
func (s *Service) SetRoot(v bool) *Service {
	s.Root = &v
	return s
}
856592
func (s *PatchOperation) SetPath(v string) *PatchOperation {
	s.Path = &v
	return s
}
650919
func (r *Router) RootPath(ctx context.Context, path string) bool {
	ns, err := namespace.FromContext(ctx)
	if err != nil {
		return false
	}

	adjustedPath := ns.Path + path

	r.l.RLock()
	mount, raw, ok := r.root.LongestPrefix(adjustedPath)
	r.l.RUnlock()
	if !ok {
		return false
	}
	re := raw.(*routeEntry)

	// Trim to get remaining path
	remain := strings.TrimPrefix(adjustedPath, mount)

	// Check the rootPaths of this backend
	rootPaths := re.rootPaths.Load().(*radix.Tree)
	match, raw, ok := rootPaths.LongestPrefix(remain)
	if !ok {
		return false
	}
	prefixMatch := raw.(bool)

	// Handle the prefix match case
	if prefixMatch {
		return strings.HasPrefix(remain, match)
	}

	// Handle the exact match case
	return match == remain
}
1108555
func (s *CreateBasePathMappingInput) SetBasePath(v string) *CreateBasePathMappingInput {
	s.BasePath = &v
	return s
}
791359
func ConfigFilePath() (configPath string, err error) {
	var usr *user.User

	if configPath = os.Getenv("GOCD_CONFIG_PATH"); configPath != "" {
		return
	}

	// @TODO Make it work for windows. Maybe...
	if usr, err = user.Current(); err != nil {
		return
	}

	configPath = strings.Replace(ConfigDirectoryPath, "~", usr.HomeDir, 1)
	return
}
760683
func (s *ScriptBootstrapActionConfig) SetPath(v string) *ScriptBootstrapActionConfig {
	s.Path = &v
	return s
}
509633
func (s *PutFileInput) SetFilePath(v string) *PutFileInput {
	s.FilePath = &v
	return s
}
251966
func (s *GetFolderOutput) SetFolderPath(v string) *GetFolderOutput {
	s.FolderPath = &v
	return s
}