MCPcopy Create free account
hub / github.com/google/go-github / resolveConfig

Function resolveConfig

tools/check-structfield-settings/main.go:136–166  ·  view source on GitHub ↗
(configPath string)

Source from the content-addressed store, hash-verified

134}
135
136func resolveConfig(configPath string) (string, string, error) {
137 if configPath != "" {
138 resolved, err := filepath.Abs(configPath)
139 if err != nil {
140 return "", "", err
141 }
142 repoRoot := filepath.Dir(resolved)
143 return resolved, repoRoot, nil
144 }
145
146 cwd, err := os.Getwd()
147 if err != nil {
148 return "", "", err
149 }
150
151 for dir := cwd; ; dir = filepath.Dir(dir) {
152 candidate := filepath.Join(dir, ".golangci.yml")
153 if _, err := os.Stat(candidate); err == nil {
154 return candidate, dir, nil
155 } else if !errors.Is(err, fs.ErrNotExist) {
156 return "", "", err
157 }
158
159 parent := filepath.Dir(dir)
160 if parent == dir {
161 break
162 }
163 }
164
165 return "", "", errors.New("unable to locate .golangci.yml")
166}
167
168func readStructfieldSettings(configPath string) ([]string, []string, map[string]bool, map[string]bool, error) {
169 data, err := os.ReadFile(configPath)

Callers 1

mainFunction · 0.85

Calls 1

IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…