copyModFiles copies go.mod and go.sum to the shadow directory, adjusting relative replace directives as needed
()
| 260 | // copyModFiles copies go.mod and go.sum to the shadow directory, |
| 261 | // adjusting relative replace directives as needed |
| 262 | func (b *Builder) copyModFiles() error { |
| 263 | // Copy go.mod with path adjustments |
| 264 | srcMod := filepath.Join(b.WorkspaceRoot, "go.mod") |
| 265 | dstMod := filepath.Join(b.ShadowDir, "go.mod") |
| 266 | |
| 267 | if err := b.copyGoMod(srcMod, dstMod); err != nil { |
| 268 | return fmt.Errorf("go.mod: %w", err) |
| 269 | } |
| 270 | |
| 271 | // Copy go.sum as-is (if exists) |
| 272 | srcSum := filepath.Join(b.WorkspaceRoot, "go.sum") |
| 273 | dstSum := filepath.Join(b.ShadowDir, "go.sum") |
| 274 | |
| 275 | if _, err := os.Stat(srcSum); err == nil { |
| 276 | if err := copyFile(srcSum, dstSum); err != nil { |
| 277 | return fmt.Errorf("go.sum: %w", err) |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | return nil |
| 282 | } |
| 283 | |
| 284 | // copyGoMod copies go.mod, adjusting relative replace directives |
| 285 | func (b *Builder) copyGoMod(src, dst string) error { |