Skip to content

Commit

Permalink
fix: remove github.com/carlmjohnson/versioninfo as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ngshiheng committed Oct 6, 2024
1 parent f227464 commit 3dadd30
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
37 changes: 31 additions & 6 deletions cmd/mym/mym.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,50 @@ package main

import (
"flag"
"fmt"
"os"

"github.com/carlmjohnson/versioninfo"
"runtime/debug"

"github.com/ngshiheng/michelin-my-maps/v2/pkg/crawler"
log "github.com/sirupsen/logrus"
)

// printVersion prints the application version
func printVersion() {
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
fmt.Println("Unable to determine version information.")
return
}

if buildInfo.Main.Version != "" {
fmt.Printf("Version: %s\n", buildInfo.Main.Version)
} else {
fmt.Println("Version: unknown")
}
}

var (
logLevel = flag.String("log", log.InfoLevel.String(), "log level (debug, info, warning, error, fatal, panic)")
helpFlag = flag.Bool("help", false, "show help message")
versionFlag = flag.Bool("version", false, "print version information")
)

func main() {
var (
logLevel = flag.String("log", log.InfoLevel.String(), "log level (debug, info, warning, error, fatal, panic)")
helpFlag = flag.Bool("help", false, "show help message")
)
versioninfo.AddFlag(nil)
flag.Parse()

if *versionFlag {
printVersion()
return
}

if *helpFlag {
flag.Usage()
return
}

// Set log level
level, err := log.ParseLevel(*logLevel)
if err != nil {
log.Errorf("failed to parse log level: %v\n", err)
Expand All @@ -30,6 +54,7 @@ func main() {
log.SetLevel(level)
log.SetOutput(os.Stdout)

// Start crawling process
app := crawler.Default()
app.Crawl()
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/ngshiheng/michelin-my-maps/v2
go 1.21

require (
github.com/carlmjohnson/versioninfo v0.22.5
github.com/gocolly/colly/v2 v2.1.0
github.com/nyaruka/phonenumbers v1.4.0
github.com/sirupsen/logrus v1.9.3
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNY
github.com/antchfx/xpath v1.1.8/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8=
github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc=
github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit 3dadd30

Please sign in to comment.