Skip to content

Commit

Permalink
Merge pull request #91 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 0.8.0
  • Loading branch information
andyone authored Dec 18, 2023
2 parents 00dfacf + 1ecbaa3 commit 2c4f2ce
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
fetch-depth: 2

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Usage: goheft {options} go-file
Options
--tags, -t tag… Build tags (mergeble)
--external, -E Shadow internal packages
--pager, -P Use pager for long output
--min-size, -m size Don't show with size less than defined
Expand All @@ -86,6 +87,9 @@ Examples
goheft application.go -m 750kb
Show size of each used library which greater than 750kb
goheft application.go -t release,slim
Use tags when building and counting size
```

### Build Status
Expand Down
24 changes: 19 additions & 5 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ import (

const (
APP = "GoHeft"
VER = "0.7.0"
VER = "0.8.0"
DESC = "Utility for listing sizes of used static libraries"
)

const (
OPT_TAGS = "t:tags"
OPT_EXTERNAL = "E:external"
OPT_PAGER = "P:pager"
OPT_MIN_SIZE = "m:min-size"
Expand Down Expand Up @@ -78,6 +79,7 @@ func (s LibInfoSlice) Less(i, j int) bool { return s[i].Size < s[j].Size }
// ////////////////////////////////////////////////////////////////////////////////// //

var optMap = options.Map{
OPT_TAGS: {Mergeble: true},
OPT_EXTERNAL: {Type: options.BOOL},
OPT_PAGER: {Type: options.BOOL},
OPT_MIN_SIZE: {},
Expand Down Expand Up @@ -323,7 +325,17 @@ func printStats(libs LibInfoSlice) {
func compileBinary(file string) (string, error) {
var workDir string

cmd := exec.Command("go", "build", "-work", "-a", "-v", file)
cmd := exec.Command("go", "build", "-work", "-a", "-v")

if options.Has(OPT_TAGS) {
cmd.Args = append(cmd.Args,
"-tags",
strings.ReplaceAll(options.GetS(OPT_TAGS), " ", ","),
)
}

cmd.Args = append(cmd.Args, file)

stderrReader, err := cmd.StderrPipe()

if err != nil {
Expand Down Expand Up @@ -416,11 +428,11 @@ func printCompletion() int {

switch options.GetS(OPT_COMPLETION) {
case "bash":
fmt.Printf(bash.Generate(info, "goheft", "go"))
fmt.Print(bash.Generate(info, "goheft", "go"))
case "fish":
fmt.Printf(fish.Generate(info, "goheft"))
fmt.Print(fish.Generate(info, "goheft"))
case "zsh":
fmt.Printf(zsh.Generate(info, optMap, "goheft", "*.go"))
fmt.Print(zsh.Generate(info, optMap, "goheft", "*.go"))
default:
return 1
}
Expand All @@ -444,6 +456,7 @@ func genUsage() *usage.Info {

info.AppNameColorTag = colorTagApp

info.AddOption(OPT_TAGS, "Build tags {s-}(mergeble){!}", "tag…")
info.AddOption(OPT_EXTERNAL, "Shadow internal packages")
info.AddOption(OPT_PAGER, "Use pager for long output")
info.AddOption(OPT_MIN_SIZE, "Don't show with size less than defined", "size")
Expand All @@ -453,6 +466,7 @@ func genUsage() *usage.Info {

info.AddExample("application.go", "Show size of each used library")
info.AddExample("application.go -m 750kb", "Show size of each used library which greater than 750kb")
info.AddExample("application.go -t release,slim", "Use tags when building and counting size")

return info
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/essentialkaos/depsy v1.1.0
github.com/essentialkaos/ek/v12 v12.90.1
github.com/essentialkaos/ek/v12 v12.92.0
)

require golang.org/x/sys v0.15.0 // indirect
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk=
github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI=
github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
github.com/essentialkaos/ek/v12 v12.90.1 h1:ID950cnz4xgpqqFzhleP5xaVoLnPwuiykdH3FrogD/E=
github.com/essentialkaos/ek/v12 v12.90.1/go.mod h1:9efMqo1S8EtYhmeelOSTmMQDGC2vRgPkjkKKfvUD2eU=
github.com/essentialkaos/ek/v12 v12.92.0 h1:3JIkHWNA6MNkJOfqzMWJ8jN9sRM7nRi7URoFRVFHZzI=
github.com/essentialkaos/ek/v12 v12.92.0/go.mod h1:9efMqo1S8EtYhmeelOSTmMQDGC2vRgPkjkKKfvUD2eU=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
Expand Down

0 comments on commit 2c4f2ce

Please sign in to comment.