Skip to content

Commit

Permalink
blockhash/main.go: Use packages.NeedName flag
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Aug 15, 2024
1 parent 5fd1432 commit fb5a7f5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmd/blockhash/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"log"
"math/bits"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
Expand All @@ -24,7 +23,7 @@ func main() {
log.Fatalln("Must pass one package to produce block hashes for.")
}
cfg := &packages.Config{
Mode: packages.NeedSyntax | packages.NeedTypes | packages.NeedTypesInfo | packages.NeedFiles,
Mode: packages.NeedName | packages.NeedSyntax | packages.NeedTypes | packages.NeedTypesInfo | packages.NeedFiles,
}
pkgs, err := packages.Load(cfg, flag.Args()[0])
if err != nil {
Expand Down Expand Up @@ -89,7 +88,7 @@ func (b *hashBuilder) sortNames() {

// writePackage writes the package at the top of the file.
func (b *hashBuilder) writePackage(w io.Writer) {
if _, err := fmt.Fprintf(w, packageFormat, filepath.Base(b.pkg.ID)); err != nil {
if _, err := fmt.Fprintf(w, packageFormat, b.pkg.Name); err != nil {
log.Fatalln(err)
}
}
Expand Down

0 comments on commit fb5a7f5

Please sign in to comment.