(ctx context.Context, sourcePath, builtPath, tags string)
| 681 | } |
| 682 | |
| 683 | func getSize(ctx context.Context, sourcePath, builtPath, tags string) (int64, error) { |
| 684 | args := []string{"build"} |
| 685 | |
| 686 | if tags != "" { |
| 687 | args = append(args, []string{"-tags", tags}...) |
| 688 | } |
| 689 | |
| 690 | args = append(args, []string{ |
| 691 | "-o", builtPath, |
| 692 | "-ldflags", "-s -w", |
| 693 | sourcePath, |
| 694 | }...) |
| 695 | |
| 696 | if err := runCmd(ctx, "go", args...); err != nil { |
| 697 | fmt.Println("issue getting size for example binary") |
| 698 | return 0, err |
| 699 | } |
| 700 | |
| 701 | fileInfo, err := os.Stat(builtPath) |
| 702 | if err != nil { |
| 703 | fmt.Println("issue getting size for example binary") |
| 704 | return 0, err |
| 705 | } |
| 706 | |
| 707 | return fileInfo.Size(), nil |
| 708 | } |
no test coverage detected