(mod string)
| 213 | } |
| 214 | |
| 215 | func getDirectProjectDependencies(mod string) ([]string, error) { |
| 216 | modPath := filepath.Join(mod, "go.mod") |
| 217 | data, err := os.ReadFile(filepath.Join(mod, "go.mod")) |
| 218 | if err != nil { |
| 219 | return nil, err |
| 220 | } |
| 221 | f, err := modfile.Parse(modPath, data, nil) |
| 222 | if err != nil { |
| 223 | return nil, err |
| 224 | } |
| 225 | var deps []string |
| 226 | base, err := getModBase(f.Module.Mod.Path) |
| 227 | if err != nil { |
| 228 | return nil, err |
| 229 | } |
| 230 | for _, require := range f.Require { |
| 231 | if strings.HasPrefix(require.Mod.Path, base) { |
| 232 | deps = append(deps, strings.TrimPrefix(require.Mod.Path, base+"/")) |
| 233 | } |
| 234 | } |
| 235 | return deps, nil |
| 236 | } |
| 237 | |
| 238 | func getModBase(modPath string) (string, error) { |
| 239 | parts := strings.SplitN(modPath, "/", 4) |
no test coverage detected