| 134 | } |
| 135 | |
| 136 | func 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 | |
| 168 | func readStructfieldSettings(configPath string) ([]string, []string, map[string]bool, map[string]bool, error) { |
| 169 | data, err := os.ReadFile(configPath) |