diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..e8600b9 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,76 @@ +name: Go + +env: + GOPATH: "/go" + GO111MODULE: "on" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Link workspace with GOPATH + run: | + sudo mkdir -vp $(dirname ${GOPATH}/src/github.com/${GITHUB_REPOSITORY}) + sudo chown -R ${USER}:users $(dirname ${GOPATH}/src/github.com/${GITHUB_REPOSITORY}) + sudo chmod ug+rw $(dirname ${GOPATH}/src/github.com/${GITHUB_REPOSITORY}) + sudo ln -svf $(pwd) ${GOPATH}/src/github.com/${GITHUB_REPOSITORY} + + - name: Check out tools into the Go module directory + run: | + git clone https://github.com/nabbar/gotools.git scripts + ./scripts/prepare + + - name: Update vendor or dependancies + run: ./scripts/ci_depend + + - name: Check goFmt & goImport + continue-on-error: true + run: ./scripts/ci_format + + - name: Check goLinter + continue-on-error: true + run: ./scripts/ci_linter + env: + GOOS: linux + CGO_ENABLED: 0 + + - name: Check goSecu + snyk.io + continue-on-error: true + run: ./scripts/ci_secu + env: + GOOS: linux + CGO_ENABLED: 0 + + - name: Add ming-w32 (x86 + win64) + run: sudo apt-get install gcc-multilib gcc-mingw-w64 + + - name: Test Build Linux/amd64 with suffix + run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -v -installsuffix cgo -ldflags "-w -s -extldflags '-static' " ./... + + - name: Test Build Linux/386 with suffix + run: CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -a -v -installsuffix cgo -ldflags "-w -s -extldflags '-static' " ./... + + - name: Test Build Windows/amd64 with CGO + run: CC=/usr/bin/x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -a -v -ldflags "-w -s -extldflags '-static' " ./... + + - name: Test Build Windows/386 with CGO + run: CC=/usr/bin/i686-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=386 go build -a -v -ldflags "-w -s -extldflags '-static' " ./... + diff --git a/README.md b/README.md index 5003f67..c20b0c3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![Go](https://github.com/nabbar/golib/workflows/Go/badge.svg) + # golib : custom lib for go snyk project : https://app.snyk.io/org/nabbar/project/2f55a2b8-6015-4db1-b859-c2bc3b7548a7 diff --git a/archive/archive.go b/archive/archive.go index 8f514f5..12b0dec 100644 --- a/archive/archive.go +++ b/archive/archive.go @@ -86,6 +86,7 @@ func ExtractFile(src *os.File, fileNameContain, fileNameRegex string) (*os.File, if _, err = src.Seek(0, 0); err != nil { e1 := FILE_SEEK.ErrorParent(err) + // #nosec if src, err = os.Open(loc); err != nil { //ErrorLevel.LogErrorCtx(DebugLevel, "reopening file", err) e2 := FILE_OPEN.ErrorParent(err) diff --git a/archive/bz2/error.go b/archive/bz2/error.go index ad07a3e..906689a 100644 --- a/archive/bz2/error.go +++ b/archive/bz2/error.go @@ -26,7 +26,7 @@ package bz2 -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Archive + 10 diff --git a/archive/bz2/reader.go b/archive/bz2/reader.go index 57bc41a..8368d95 100644 --- a/archive/bz2/reader.go +++ b/archive/bz2/reader.go @@ -44,6 +44,7 @@ func GetFile(src *os.File, filenameContain, filenameRegex string) (dst *os.File, r := bzip2.NewReader(src) + // #nosec if t, e := iou.NewTempFile(); e != nil { //ErrorLevel.LogErrorCtx(DebugLevel, "init new temporary buffer", e) return nil, e diff --git a/archive/error.go b/archive/error.go index f223a26..8d0b4d9 100644 --- a/archive/error.go +++ b/archive/error.go @@ -26,7 +26,7 @@ package archive -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Archive diff --git a/archive/gzip/error.go b/archive/gzip/error.go index 3bb6b92..b093d16 100644 --- a/archive/gzip/error.go +++ b/archive/gzip/error.go @@ -26,7 +26,7 @@ package gzip -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Archive + 20 diff --git a/archive/gzip/reader.go b/archive/gzip/reader.go index 5f061a0..b20aad1 100644 --- a/archive/gzip/reader.go +++ b/archive/gzip/reader.go @@ -50,6 +50,7 @@ func GetFile(src *os.File, filenameContain, filenameRegex string) (dst *os.File, defer r.Close() + // #nosec if t, e := iou.NewTempFile(); e != nil { //ErrorLevel.LogErrorCtx(DebugLevel, "init new temporary buffer", e) return nil, e diff --git a/archive/tar/error.go b/archive/tar/error.go index 25a58e4..f544385 100644 --- a/archive/tar/error.go +++ b/archive/tar/error.go @@ -26,7 +26,7 @@ package tar -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Archive + 30 diff --git a/archive/tar/reader.go b/archive/tar/reader.go index e3750a6..221c783 100644 --- a/archive/tar/reader.go +++ b/archive/tar/reader.go @@ -61,6 +61,8 @@ func GetFile(src *os.File, filenameContain, filenameRegex string) (dst *os.File, } f := archive.NewFileFullPath(h.Name) + + // #nosec if f.MatchingFullPath(filenameContain) || f.RegexFullPath(filenameRegex) { if t, e := iou.NewTempFile(); e != nil { //ErrorLevel.LogErrorCtx(DebugLevel, "init new temporary buffer", e) diff --git a/archive/zip/error.go b/archive/zip/error.go index 839f56c..93a4b7d 100644 --- a/archive/zip/error.go +++ b/archive/zip/error.go @@ -26,7 +26,7 @@ package zip -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Archive + 40 diff --git a/archive/zip/reader.go b/archive/zip/reader.go index 8b95971..31c08ca 100644 --- a/archive/zip/reader.go +++ b/archive/zip/reader.go @@ -93,6 +93,7 @@ func extratFile(f *zip.File) (dst *os.File, err Error) { _ = r.Close() }() + // #nosec if dst, err = iou.NewTempFile(); err != nil { //ErrorLevel.LogErrorCtx(DebugLevel, "init new temporary buffer", err) return diff --git a/certificates/error.go b/certificates/error.go index 191e348..b1421a4 100644 --- a/certificates/error.go +++ b/certificates/error.go @@ -26,7 +26,7 @@ package certificates -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Certif diff --git a/certificates/tlsTools.go b/certificates/tlsTools.go index 93717eb..2815dbb 100644 --- a/certificates/tlsTools.go +++ b/certificates/tlsTools.go @@ -298,6 +298,7 @@ func SetSessionTicket(enable bool) { } func GetTLSConfig(serverName string) *tls.Config { + // #nosec cnf := &tls.Config{ RootCAs: rootCA, ClientCAs: caCertificates, diff --git a/console/error.go b/console/error.go index 4dbc9c0..5016205 100644 --- a/console/error.go +++ b/console/error.go @@ -26,7 +26,7 @@ package console -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Console diff --git a/httpcli/cli.go b/httpcli/cli.go index c46de8f..2d7f69c 100644 --- a/httpcli/cli.go +++ b/httpcli/cli.go @@ -36,7 +36,7 @@ import ( . "github.com/nabbar/golib/errors" - njs_certif "github.com/nabbar/golib/certificates" + certif "github.com/nabbar/golib/certificates" ) const ( @@ -47,21 +47,21 @@ const ( ) func GetClient(serverName string) *http.Client { - c, e := getClient(true, TIMEOUT_30_SEC, TIMEOUT_10_SEC, TIMEOUT_30_SEC, TIMEOUT_30_SEC, TIMEOUT_5_SEC, TIMEOUT_1_SEC, njs_certif.GetTLSConfig(serverName)) + c, e := getClient(true, TIMEOUT_30_SEC, TIMEOUT_10_SEC, TIMEOUT_30_SEC, TIMEOUT_30_SEC, TIMEOUT_5_SEC, TIMEOUT_1_SEC, certif.GetTLSConfig(serverName)) if e != nil { - c, _ = getClient(false, TIMEOUT_30_SEC, TIMEOUT_10_SEC, TIMEOUT_30_SEC, TIMEOUT_30_SEC, TIMEOUT_5_SEC, TIMEOUT_1_SEC, njs_certif.GetTLSConfig(serverName)) + c, _ = getClient(false, TIMEOUT_30_SEC, TIMEOUT_10_SEC, TIMEOUT_30_SEC, TIMEOUT_30_SEC, TIMEOUT_5_SEC, TIMEOUT_1_SEC, certif.GetTLSConfig(serverName)) } return c } func GetClientError(serverName string) (*http.Client, Error) { - return getClient(true, TIMEOUT_30_SEC, TIMEOUT_10_SEC, TIMEOUT_30_SEC, TIMEOUT_30_SEC, TIMEOUT_5_SEC, TIMEOUT_1_SEC, njs_certif.GetTLSConfig(serverName)) + return getClient(true, TIMEOUT_30_SEC, TIMEOUT_10_SEC, TIMEOUT_30_SEC, TIMEOUT_30_SEC, TIMEOUT_5_SEC, TIMEOUT_1_SEC, certif.GetTLSConfig(serverName)) } func GetClientTimeout(serverName string, GlobalTimeout, DialTimeOut, DialKeepAlive, IdleConnTimeout, TLSHandshakeTimeout, ExpectContinueTimeout time.Duration) (*http.Client, Error) { - return getClient(true, GlobalTimeout, DialTimeOut, DialKeepAlive, IdleConnTimeout, TLSHandshakeTimeout, ExpectContinueTimeout, njs_certif.GetTLSConfig(serverName)) + return getClient(true, GlobalTimeout, DialTimeOut, DialKeepAlive, IdleConnTimeout, TLSHandshakeTimeout, ExpectContinueTimeout, certif.GetTLSConfig(serverName)) } func getClient(http2Transport bool, GlobalTimeout, DialTimeOut, DialKeepAlive, IdleConnTimeout, TLSHandshakeTimeout, ExpectContinueTimeout time.Duration, tlsConfig *tls.Config) (*http.Client, Error) { diff --git a/httpcli/error.go b/httpcli/error.go index 52a5180..1f4013d 100644 --- a/httpcli/error.go +++ b/httpcli/error.go @@ -26,7 +26,7 @@ package httpcli -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Httpcli diff --git a/httpserver/error.go b/httpserver/error.go index 68813ae..9aa6a46 100644 --- a/httpserver/error.go +++ b/httpserver/error.go @@ -26,7 +26,7 @@ package httpserver -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Httpserver diff --git a/httpserver/http.go b/httpserver/http.go index 383acea..7c121cc 100644 --- a/httpserver/http.go +++ b/httpserver/http.go @@ -42,7 +42,7 @@ import ( "golang.org/x/net/http2" - njs_certif "github.com/nabbar/golib/certificates" + certif "github.com/nabbar/golib/certificates" . "github.com/nabbar/golib/logger" ) @@ -199,7 +199,7 @@ func (srv *modelServer) Listen() { FatalLevel.Logf("Configuring Server '%s' Error: %v", srv.host, err) go func() { - if srv.ssl == nil || !njs_certif.CheckCertificates() { + if srv.ssl == nil || !certif.CheckCertificates() { InfoLevel.Logf("Server '%s' is starting with bindable: %s", srv.host, srv.GetBindable()) if err := srv.srv.ListenAndServe(); err != nil { FatalLevel.Logf("Listen Server '%s' Error: %v", srv.host, err) diff --git a/ioutils/error.go b/ioutils/error.go index 19f0741..15fdd05 100644 --- a/ioutils/error.go +++ b/ioutils/error.go @@ -26,7 +26,7 @@ package ioutils -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_IOUtils diff --git a/ioutils/maxstdio/maxstdio.go b/ioutils/maxstdio/maxstdio.go index bdc82bf..112a5ff 100644 --- a/ioutils/maxstdio/maxstdio.go +++ b/ioutils/maxstdio/maxstdio.go @@ -1,4 +1,4 @@ -// +build windows cgo +// +build windows,cgo package maxstdio diff --git a/ldap/error.go b/ldap/error.go index 97622a9..0f94740 100644 --- a/ldap/error.go +++ b/ldap/error.go @@ -26,7 +26,7 @@ package ldap -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_LDAP diff --git a/ldap/ldap.go b/ldap/ldap.go index dbcb832..8966efc 100644 --- a/ldap/ldap.go +++ b/ldap/ldap.go @@ -32,7 +32,7 @@ import ( "github.com/go-ldap/ldap/v3" - njs_certif "github.com/nabbar/golib/certificates" + certif "github.com/nabbar/golib/certificates" . "github.com/nabbar/golib/errors" . "github.com/nabbar/golib/logger" ) @@ -56,7 +56,7 @@ func NewLDAP(cnf *Config, attributes []string) (*HelperLDAP, Error) { return &HelperLDAP{ Attributes: attributes, - tlsConfig: njs_certif.GetTLSConfig(cnf.Uri), + tlsConfig: certif.GetTLSConfig(cnf.Uri), tlsMode: tlsmode_init, config: cnf.Clone(), }, nil diff --git a/smtp/attachment.go b/smtp/attachment.go index aa9958a..ed57a5d 100644 --- a/smtp/attachment.go +++ b/smtp/attachment.go @@ -95,6 +95,7 @@ func NewAttachmentFile(name string, filepath string) (Attachment, Error) { return nil, FILE_STAT.ErrorParent(e) } + // #nosec if bb, e := ioutil.ReadFile(filepath); e != nil { return nil, FILE_READ.ErrorParent(e) } else { diff --git a/smtp/config.go b/smtp/config.go index abeddcf..664e709 100644 --- a/smtp/config.go +++ b/smtp/config.go @@ -34,7 +34,7 @@ import ( "strconv" "strings" - njs_certif "github.com/nabbar/golib/certificates" + certif "github.com/nabbar/golib/certificates" . "github.com/nabbar/golib/errors" ) @@ -264,7 +264,7 @@ func newSMTPConfig(dsn string) (*smtpConfig, Error) { // - net aceeptable are : tcp4, tcp6, unix func NewSMTP(dsn string, tlsConfig *tls.Config) (SMTP, Error) { if tlsConfig == nil { - tlsConfig = njs_certif.GetTLSConfig("") + tlsConfig = certif.GetTLSConfig("") } if c, e := newSMTPConfig(dsn); e != nil { diff --git a/smtp/error.go b/smtp/error.go index a8dc8bb..5b005df 100644 --- a/smtp/error.go +++ b/smtp/error.go @@ -26,7 +26,7 @@ package smtp -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_SMTP diff --git a/smtp/mail.go b/smtp/mail.go index 147cbf2..cc205da 100644 --- a/smtp/mail.go +++ b/smtp/mail.go @@ -155,6 +155,7 @@ func NewMailTemplate(name, tpl string, isFile bool) (MailTemplate, Error) { if isFile { var fs []byte + // #nosec if _, err = os.Stat(tpl); err != nil { return nil, FILE_STAT.ErrorParent(err) } else if fs, err = ioutil.ReadFile(tpl); err != nil { diff --git a/smtp/sendmail.go b/smtp/sendmail.go index 3753860..736506d 100644 --- a/smtp/sendmail.go +++ b/smtp/sendmail.go @@ -31,7 +31,7 @@ import ( "net/smtp" "time" - vers "github.com/nabbar/golib/version" + "github.com/nabbar/golib/version" . "github.com/nabbar/golib/errors" ) @@ -138,7 +138,7 @@ func (s *sendmail) SetMailer(mailer string) { s.mailer = mailer } -func (s *sendmail) NJSMailer(version vers.Version) { +func (s *sendmail) NJSMailer(version version.Version) { s.mailer = version.GetHeader() } @@ -451,7 +451,7 @@ type SendMail interface { SetMessageId(id string) SetMailer(mailer string) - NJSMailer(version vers.Version) + NJSMailer(version version.Version) SetTestMode(enable bool) diff --git a/static/error.go b/static/error.go index 18c7e46..a60e366 100644 --- a/static/error.go +++ b/static/error.go @@ -26,7 +26,7 @@ package static -import errors "github.com/nabbar/golib/errors" +import "github.com/nabbar/golib/errors" const ( EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Static diff --git a/status/status.go b/status/status.go index 332b89e..e5cecf8 100644 --- a/status/status.go +++ b/status/status.go @@ -31,9 +31,8 @@ import ( "path" "strings" - njs_router "github.com/nabbar/golib/router" - - njs_version "github.com/nabbar/golib/version" + "github.com/nabbar/golib/router" + "github.com/nabbar/golib/version" "github.com/gin-gonic/gin" ) @@ -80,20 +79,20 @@ type mainPackage struct { } type initLater struct { - version func() njs_version.Version + version func() version.Version info func() (name, release, build string) msg func() (ok string, ko string) health func() error } type Status interface { - Register(prefix string, register njs_router.RegisterRouter) + Register(prefix string, register router.RegisterRouter) AddComponent(name, msgOK, msgKO, release, build string, WarnIfError bool, health func() error) - AddVersionComponent(vers njs_version.Version, msgOK, msgKO string, WarnIfError bool, health func() error) + AddVersionComponent(vers version.Version, msgOK, msgKO string, WarnIfError bool, health func() error) LaterAddComponent(info func() (name, release, build string), msg func() (ok string, ko string), health func() error, WarnIfError bool) - LaterAddVersionComponent(vers func() njs_version.Version, msg func() (ok string, ko string), health func() error, WarnIfError bool) + LaterAddVersionComponent(vers func() version.Version, msg func() (ok string, ko string), health func() error, WarnIfError bool) Get(c *gin.Context) } @@ -122,7 +121,7 @@ func NewStatus(name, msgOK, msgKO, release, build string, health func() error, H } } -func NewVersionStatusLater(vers func() njs_version.Version, msg func() (ok string, ko string), health func() error, Header gin.HandlerFunc) Status { +func NewVersionStatusLater(vers func() version.Version, msg func() (ok string, ko string), health func() error, Header gin.HandlerFunc) Status { return &mainPackage{ cpt: make([]statusComponent, 0), header: Header, @@ -136,7 +135,7 @@ func NewVersionStatusLater(vers func() njs_version.Version, msg func() (ok strin } } -func NewVersionStatus(vers njs_version.Version, msgOK, msgKO string, health func() error, Header gin.HandlerFunc) Status { +func NewVersionStatus(vers version.Version, msgOK, msgKO string, health func() error, Header gin.HandlerFunc) Status { return NewStatus(vers.GetPackage(), msgOK, msgKO, vers.GetRelease(), vers.GetBuild(), health, Header) } @@ -171,11 +170,11 @@ func (p *mainPackage) LaterAddComponent(info func() (name, release, build string }) } -func (p *mainPackage) AddVersionComponent(vers njs_version.Version, msgOK, msgKO string, WarnIfError bool, health func() error) { +func (p *mainPackage) AddVersionComponent(vers version.Version, msgOK, msgKO string, WarnIfError bool, health func() error) { p.AddComponent(vers.GetPackage(), msgOK, msgKO, vers.GetRelease(), vers.GetBuild(), WarnIfError, health) } -func (p *mainPackage) LaterAddVersionComponent(vers func() njs_version.Version, msg func() (ok string, ko string), health func() error, WarnIfError bool) { +func (p *mainPackage) LaterAddVersionComponent(vers func() version.Version, msg func() (ok string, ko string), health func() error, WarnIfError bool) { p.cpt = append(p.cpt, statusComponent{ WarnIfErr: WarnIfError, later: &initLater{ @@ -244,7 +243,7 @@ func (p *mainPackage) cleanPrefix(prefix string) string { return path.Clean(strings.TrimRight(path.Join("/", prefix), "/")) } -func (p *mainPackage) Register(prefix string, register njs_router.RegisterRouter) { +func (p *mainPackage) Register(prefix string, register router.RegisterRouter) { prefix = p.cleanPrefix(prefix) register(http.MethodGet, prefix, p.header, p.Get) @@ -254,7 +253,7 @@ func (p *mainPackage) Register(prefix string, register njs_router.RegisterRouter } } -func (p *mainPackage) RegisterGroup(group, prefix string, register njs_router.RegisterRouterInGroup) { +func (p *mainPackage) RegisterGroup(group, prefix string, register router.RegisterRouterInGroup) { prefix = p.cleanPrefix(prefix) register(group, http.MethodGet, prefix, p.header, p.Get) diff --git a/test/test-archive/main.go b/test/test-archive/main.go index 1645635..0970619 100644 --- a/test/test-archive/main.go +++ b/test/test-archive/main.go @@ -30,9 +30,8 @@ import ( "io/ioutil" "os" - njs_archive "github.com/nabbar/golib/archive" - - iou "github.com/nabbar/golib/ioutils" + "github.com/nabbar/golib/archive" + "github.com/nabbar/golib/ioutils" ) // git archive --format=tar --output=git.tar HEAD @@ -61,19 +60,19 @@ func main() { _ = src.Close() }() - if tmp, err = iou.NewTempFile(); err != nil { + if tmp, err = ioutils.NewTempFile(); err != nil { panic(err) } defer func() { - _ = iou.DelTempFile(tmp) + _ = ioutils.DelTempFile(tmp) }() if _, err = io.Copy(tmp, src); err != nil { panic(err) } - if rio, err = njs_archive.ExtractFile(tmp, contain, regex); err != nil { + if rio, err = archive.ExtractFile(tmp, contain, regex); err != nil { panic(err) } diff --git a/test/test-progressbar/main.go b/test/test-progressbar/main.go index c5973a1..611e157 100644 --- a/test/test-progressbar/main.go +++ b/test/test-progressbar/main.go @@ -29,19 +29,19 @@ import ( "math/rand" "time" - npb "github.com/nabbar/golib/progress" + "github.com/nabbar/golib/progress" "github.com/vbauerster/mpb/v5" ) var ( - pb npb.ProgressBar - br npb.Bar + pb progress.ProgressBar + br progress.Bar ) func main() { println("Starting...") - pb = npb.NewProgressBar(0, time.Time{}, nil, mpb.WithWidth(64)) + pb = progress.NewProgressBar(0, time.Time{}, nil, mpb.WithWidth(64)) pb.SetSemaphoreOption(0, 0) br = pb.NewBarSimpleETA("test bar") @@ -54,11 +54,11 @@ func main() { continue } - go func(id int) { + go func() { defer br.DeferWorker() rand.Seed(9999) time.Sleep(time.Duration(rand.Intn(999)) * time.Millisecond) - }(i) + }() } if e := br.WaitAll(); e != nil { diff --git a/test/test-win-max-nofile/main.go b/test/test-win-max-nofile/main.go index ba751c0..8a5c858 100644 --- a/test/test-win-max-nofile/main.go +++ b/test/test-win-max-nofile/main.go @@ -4,12 +4,12 @@ import ( "fmt" "os" - njs_ioutils "github.com/nabbar/golib/ioutils" + "github.com/nabbar/golib/ioutils" ) func main() { println("test to print Max STDIO NOFILE capabilities !!") - c, _, e := njs_ioutils.SystemFileDescriptor(0) + c, _, e := ioutils.SystemFileDescriptor(0) println(fmt.Sprintf("Actual limit is : %v | err : %v", c, e)) if e != nil { @@ -17,7 +17,7 @@ func main() { } println("test to Change Max STDIO NOFILE capabilities !!") - c, _, e = njs_ioutils.SystemFileDescriptor(c + 512) + c, _, e = ioutils.SystemFileDescriptor(c + 512) println(fmt.Sprintf("New limit is : %v | err : %v", c, e)) if e != nil { diff --git a/version/version.go b/version/version.go index bf5c476..1bbc75d 100644 --- a/version/version.go +++ b/version/version.go @@ -30,9 +30,8 @@ import ( "path" "reflect" "runtime" - "time" - "strings" + "time" govers "github.com/hashicorp/go-version" . "github.com/nabbar/golib/errors"