From 7049c65d156e3d1b76443aa233d2050df0b68070 Mon Sep 17 00:00:00 2001 From: Kay Date: Wed, 24 Jul 2024 02:32:22 +0330 Subject: [PATCH] refactor(errors): defining errors in proper way (#129) --- .github/workflows/linting.yml | 2 +- .github/workflows/releaser.yml | 2 +- .github/workflows/testing.yml | 4 ++-- .gitignore | 34 +++++-------------------------- Makefile | 2 +- cmd/commands/errors.go | 19 +++++++++++++++++ cmd/commands/init.go | 2 +- cmd/commands/repl.go | 5 +++-- cmd/commands/run.go | 19 +++++++++-------- cmd/main.go | 6 +++--- config/config.go | 10 ++++++--- config/config_test.go | 5 ++--- config/errors.go | 11 ++++++++++ core/TQL/execute/execute.go | 2 +- core/TQL/execute/execute_test.go | 6 +++--- core/TQL/parser/parser.go | 2 +- core/database/database.go | 2 +- core/database/database_test.go | 2 +- core/server/errors.go | 11 ++++++++++ core/server/server.go | 35 +++++++++++++++++--------------- go.mod | 11 +++++----- go.sum | 20 ++++++++++-------- {utils/log => log}/logger.go | 2 +- utils/errors/errors.go | 17 ---------------- 24 files changed, 122 insertions(+), 109 deletions(-) create mode 100644 cmd/commands/errors.go create mode 100644 config/errors.go create mode 100644 core/server/errors.go rename {utils/log => log}/logger.go (98%) delete mode 100644 utils/errors/errors.go diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index a614e95..6c02809 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.21.1' + go-version: '1.22.2' cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v6 diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index ab6d547..8899d59 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -29,7 +29,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: 1.21.1 + go-version: '1.22.2' - name: Create release files run: bash ./.github/releaser/release_cli.sh diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 046d134..53138d1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -23,7 +23,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: '1.21.1' + go-version: '1.22.2' - name: Unit tests - run: make unit_test \ No newline at end of file + run: make unit-test \ No newline at end of file diff --git a/.gitignore b/.gitignore index cf7bbc6..c5c2b31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,36 +1,12 @@ -# Compiled binary files -*.exe -*.out -*.dll -*.so -*.dylib - -# Compiled object files -*.o - -# Go binary and test coverage reports -*.test -*.prof - -# Dependency directories (remove these if using Go modules) -/vendor/ -/Godeps/ - # Ignore IDE and editor-specific files .vscode/ .idea/ *.sublime-project *.sublime-workspace -# OS-specific files -.DS_Store -Thumbs.db - -# dev files -cmd/config.yaml -/client -log.ttrace -build/ +# Development files +client +build -# python cache files -test/__pycache__ +# Cache files +*cache* \ No newline at end of file diff --git a/Makefile b/Makefile index bc5848f..8752ea7 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ build-cli: go build -o ./build/ttrace ./cmd/main.go ### Testing -unit_test: +unit-test: go test $(PACKAGES) test: diff --git a/cmd/commands/errors.go b/cmd/commands/errors.go new file mode 100644 index 0000000..153d41d --- /dev/null +++ b/cmd/commands/errors.go @@ -0,0 +1,19 @@ +package commands + +import "fmt" + +type InvalidAuthInfoError struct { + command string +} + +func (e InvalidAuthInfoError) Error() string { + return fmt.Sprintf("command %s is not a valid command to authenticate", e.command) +} + +type InvalidConfigPathError struct { + path string +} + +func (e InvalidConfigPathError) Error() string { + return fmt.Sprintf("path %s doesn't contain a valid config file", e.path) +} diff --git a/cmd/commands/init.go b/cmd/commands/init.go index 5d3670e..0240bb1 100644 --- a/cmd/commands/init.go +++ b/cmd/commands/init.go @@ -5,7 +5,7 @@ import ( "os" cobra "github.com/spf13/cobra" - "github.com/zurvan-lab/TimeTrace/config" + "github.com/zurvan-lab/timetrace/config" ) func InitCommand(parentCmd *cobra.Command) { diff --git a/cmd/commands/repl.go b/cmd/commands/repl.go index f4da40b..15f6736 100644 --- a/cmd/commands/repl.go +++ b/cmd/commands/repl.go @@ -10,7 +10,6 @@ import ( "github.com/peterh/liner" cobra "github.com/spf13/cobra" - "github.com/zurvan-lab/TimeTrace/utils/errors" ) /* @@ -94,7 +93,9 @@ func ConnectCommand(parentCmd *cobra.Command) { } } } else { - ExitOnError(cmd, fmt.Errorf("%w: %s", errors.ErrInvalidCommand, response)) + ExitOnError(cmd, fmt.Errorf("%w: %s", InvalidAuthInfoError{ + command: conQuery, + }, response)) } } } diff --git a/cmd/commands/run.go b/cmd/commands/run.go index d0ce974..9e42a20 100644 --- a/cmd/commands/run.go +++ b/cmd/commands/run.go @@ -2,11 +2,10 @@ package commands import ( cobra "github.com/spf13/cobra" - "github.com/zurvan-lab/TimeTrace/config" - "github.com/zurvan-lab/TimeTrace/core/database" - "github.com/zurvan-lab/TimeTrace/core/server" - tte "github.com/zurvan-lab/TimeTrace/utils/errors" - ttlog "github.com/zurvan-lab/TimeTrace/utils/log" + "github.com/zurvan-lab/timetrace/config" + "github.com/zurvan-lab/timetrace/core/database" + "github.com/zurvan-lab/timetrace/core/server" + ttlog "github.com/zurvan-lab/timetrace/log" ) func RunCommand(parentCmd *cobra.Command) { @@ -16,14 +15,16 @@ func RunCommand(parentCmd *cobra.Command) { } parentCmd.AddCommand(run) - confingPath := run.Flags().StringP("config", "c", "", "Path to your config.yaml file.") + configPath := run.Flags().StringP("config", "c", "", "Path to your config.yaml file.") run.Run = func(cmd *cobra.Command, args []string) { - if confingPath == nil || *confingPath == "" { - ExitOnError(cmd, tte.ErrInavlidConfigPath) + if configPath == nil || *configPath == "" { + ExitOnError(cmd, InvalidConfigPathError{ + path: *configPath, + }) } - cfg, err := config.LoadFromFile(*confingPath) + cfg, err := config.LoadFromFile(*configPath) if err != nil { ExitOnError(cmd, err) } diff --git a/cmd/main.go b/cmd/main.go index 4d24d3d..8cc2af5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -2,14 +2,14 @@ package main import ( "github.com/spf13/cobra" - timetrace "github.com/zurvan-lab/TimeTrace" - "github.com/zurvan-lab/TimeTrace/cmd/commands" + tt "github.com/zurvan-lab/timetrace" + "github.com/zurvan-lab/timetrace/cmd/commands" ) func main() { rootCmd := &cobra.Command{ Use: "ttrace", - Version: timetrace.StringVersion(), + Version: tt.StringVersion(), } commands.RunCommand(rootCmd) diff --git a/config/config.go b/config/config.go index c563c99..332c37f 100644 --- a/config/config.go +++ b/config/config.go @@ -6,7 +6,6 @@ import ( "os" "slices" - tte "github.com/zurvan-lab/TimeTrace/utils/errors" "gopkg.in/yaml.v2" ) @@ -44,7 +43,9 @@ type User struct { func (conf *Config) BasicCheck() error { if len(conf.Users) == 0 { - return tte.ErrInvalidUsers + return BasicCheckError{ + reason: "at least one user must be defined in config", + } } for _, u := range conf.Users { @@ -57,7 +58,10 @@ func (conf *Config) BasicCheck() error { } if allCmds && len(u.Cmds) > 1 { - return tte.ErrSpecificAndAllCommandSameAtTime + return BasicCheckError{ + reason: "you can't use all (*) commands and specific commands" + + " permission for one user at the same time", + } } } diff --git a/config/config_test.go b/config/config_test.go index 1ee5176..f0d985c 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - tte "github.com/zurvan-lab/TimeTrace/utils/errors" ) func TestDefaultConfig(t *testing.T) { @@ -56,10 +55,10 @@ func TestBasicCheck(t *testing.T) { c.Users = []User{} err = c.BasicCheck() - assert.Error(t, tte.ErrInvalidUsers, err) + assert.Error(t, BasicCheckError{}, err) c.Users = []User{DefaultConfig().Users[0]} c.Users[0].Cmds = []string{"*", "GET"} err = c.BasicCheck() - assert.Error(t, tte.ErrSpecificAndAllCommandSameAtTime, err) + assert.Error(t, BasicCheckError{}, err) } diff --git a/config/errors.go b/config/errors.go new file mode 100644 index 0000000..41e1b6a --- /dev/null +++ b/config/errors.go @@ -0,0 +1,11 @@ +package config + +import "fmt" + +type BasicCheckError struct { + reason string +} + +func (e BasicCheckError) Error() string { + return fmt.Sprintf("config basic check failed: %s", e.reason) +} diff --git a/core/TQL/execute/execute.go b/core/TQL/execute/execute.go index 4479a84..da3abde 100644 --- a/core/TQL/execute/execute.go +++ b/core/TQL/execute/execute.go @@ -1,6 +1,6 @@ package execute -import "github.com/zurvan-lab/TimeTrace/core/database" +import "github.com/zurvan-lab/timetrace/core/database" type Executor func(database.IDataBase, []string) string diff --git a/core/TQL/execute/execute_test.go b/core/TQL/execute/execute_test.go index 4c0ac74..cc6a70e 100644 --- a/core/TQL/execute/execute_test.go +++ b/core/TQL/execute/execute_test.go @@ -4,9 +4,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zurvan-lab/TimeTrace/config" - "github.com/zurvan-lab/TimeTrace/core/TQL/parser" - "github.com/zurvan-lab/TimeTrace/core/database" + "github.com/zurvan-lab/timetrace/config" + "github.com/zurvan-lab/timetrace/core/TQL/parser" + "github.com/zurvan-lab/timetrace/core/database" ) func TestExecute(t *testing.T) { diff --git a/core/TQL/parser/parser.go b/core/TQL/parser/parser.go index 62acebc..9dd3255 100644 --- a/core/TQL/parser/parser.go +++ b/core/TQL/parser/parser.go @@ -3,7 +3,7 @@ package core import ( "strings" - "github.com/zurvan-lab/TimeTrace/core/database" + "github.com/zurvan-lab/timetrace/core/database" ) // parsing TQL queries. see: docs/TQL. diff --git a/core/database/database.go b/core/database/database.go index e3b2f4e..789d83d 100644 --- a/core/database/database.go +++ b/core/database/database.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "github.com/zurvan-lab/TimeTrace/config" + "github.com/zurvan-lab/timetrace/config" ) type Database struct { diff --git a/core/database/database_test.go b/core/database/database_test.go index 068788a..449698e 100644 --- a/core/database/database_test.go +++ b/core/database/database_test.go @@ -8,7 +8,7 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/zurvan-lab/TimeTrace/config" + "github.com/zurvan-lab/timetrace/config" ) func TestDataBase(t *testing.T) { diff --git a/core/server/errors.go b/core/server/errors.go new file mode 100644 index 0000000..c927a91 --- /dev/null +++ b/core/server/errors.go @@ -0,0 +1,11 @@ +package server + +import "fmt" + +type AuthenticateError struct { + reason string +} + +func (e AuthenticateError) Error() string { + return fmt.Sprintf("auth error: %s", e.reason) +} diff --git a/core/server/server.go b/core/server/server.go index bc58ce9..f604380 100644 --- a/core/server/server.go +++ b/core/server/server.go @@ -8,12 +8,11 @@ import ( "sync" "syscall" - "github.com/zurvan-lab/TimeTrace/config" - "github.com/zurvan-lab/TimeTrace/core/TQL/execute" - parser "github.com/zurvan-lab/TimeTrace/core/TQL/parser" - "github.com/zurvan-lab/TimeTrace/core/database" - "github.com/zurvan-lab/TimeTrace/utils/errors" - ttlogger "github.com/zurvan-lab/TimeTrace/utils/log" + "github.com/zurvan-lab/timetrace/config" + "github.com/zurvan-lab/timetrace/core/TQL/execute" + parser "github.com/zurvan-lab/timetrace/core/TQL/parser" + "github.com/zurvan-lab/timetrace/core/database" + ttlog "github.com/zurvan-lab/timetrace/log" ) type Server struct { @@ -48,14 +47,14 @@ func (s *Server) Start() error { s.Listener = listener - ttlogger.Info("server started", "address", s.ListenAddress, "db-name", s.Config.Name) + ttlog.Info("server started", "address", s.ListenAddress, "db-name", s.Config.Name) signalChan := make(chan os.Signal, 1) signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) go func() { sig := <-signalChan - ttlogger.Info("Received signal, shutting down...", "signal", sig, "db-name", s.Config.Name) + ttlog.Info("Received signal, shutting down...", "signal", sig, "db-name", s.Config.Name) close(s.QuitChan) s.Stop() @@ -81,20 +80,20 @@ func (s *Server) AcceptConnections() { conn, err := s.Listener.Accept() if err != nil { - ttlogger.Error("error accepting connection", "error", err, "db-name", s.Config.Name) + ttlog.Error("error accepting connection", "error", err, "db-name", s.Config.Name) continue } user, err := s.Authenticate(conn) if err != nil { - ttlogger.Warn("invalid user try to connect", "db-name", s.Config.Name) + ttlog.Warn("invalid user try to connect", "db-name", s.Config.Name) } else { s.ActiveConnsMux.Lock() s.ActiveConnections[conn] = user s.ActiveConnsMux.Unlock() - ttlogger.Info("new connection", "remote address", conn.RemoteAddr().String(), "db-name", s.Config.Name) + ttlog.Info("new connection", "remote address", conn.RemoteAddr().String(), "db-name", s.Config.Name) s.Wg.Add(1) go s.HandleConnection(conn) @@ -113,7 +112,7 @@ func (s *Server) HandleConnection(conn net.Conn) { n, err := conn.Read(buffer) if err != nil { - ttlogger.Info("Connection closed", "remote address", conn.RemoteAddr().String(), "db-name", s.Config.Name) + ttlog.Info("Connection closed", "remote address", conn.RemoteAddr().String(), "db-name", s.Config.Name) s.ActiveConnsMux.Lock() delete(s.ActiveConnections, conn) @@ -129,7 +128,7 @@ func (s *Server) HandleConnection(conn net.Conn) { _, err = conn.Write([]byte(result)) if err != nil { - ttlogger.Error("Can't write on TCP connection", "error", err, "db-name", s.Config.Name) + ttlog.Error("Can't write on TCP connection", "error", err, "db-name", s.Config.Name) } } else { _, _ = conn.Write([]byte(database.INVALID)) @@ -142,7 +141,7 @@ func (s *Server) Authenticate(conn net.Conn) (*config.User, error) { n, err := conn.Read(buffer) if err != nil { - ttlogger.Error("error reading connection", "error", err, "db-name", s.Config.Name) + ttlog.Error("error reading connection", "error", err, "db-name", s.Config.Name) _ = conn.Close() } @@ -151,14 +150,18 @@ func (s *Server) Authenticate(conn net.Conn) (*config.User, error) { if query.Command != "CON" { _ = conn.Close() - return nil, errors.ErrAuth + return nil, AuthenticateError{ + reason: "user need to make a session first", + } } result := execute.Execute(query, s.db) if result != database.OK { _ = conn.Close() - return nil, errors.ErrAuth + return nil, AuthenticateError{ + reason: "user name or password is invalid", + } } _, _ = conn.Write([]byte(result)) diff --git a/go.mod b/go.mod index 235bd70..2ef1ece 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ -module github.com/zurvan-lab/TimeTrace +module github.com/zurvan-lab/timetrace go 1.22.2 require ( github.com/peterh/liner v1.2.2 - github.com/rs/zerolog v1.32.0 - github.com/spf13/cobra v1.8.0 + github.com/rs/zerolog v1.33.0 + github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -15,10 +15,11 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.3 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.22.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index bb7916b..6ee5a2d 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -11,19 +11,23 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw= github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= @@ -32,8 +36,8 @@ golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= diff --git a/utils/log/logger.go b/log/logger.go similarity index 98% rename from utils/log/logger.go rename to log/logger.go index 47e6d71..69c8945 100644 --- a/utils/log/logger.go +++ b/log/logger.go @@ -11,7 +11,7 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "github.com/zurvan-lab/TimeTrace/config" + "github.com/zurvan-lab/timetrace/config" "gopkg.in/natefinch/lumberjack.v2" ) diff --git a/utils/errors/errors.go b/utils/errors/errors.go deleted file mode 100644 index 9d5b42c..0000000 --- a/utils/errors/errors.go +++ /dev/null @@ -1,17 +0,0 @@ -package errors - -import "errors" - -var ( - // Config errors. - ErrInavlidConfigPath = errors.New("invalid config path") - ErrInvalidUsers = errors.New("invalid user(s)") - ErrSpecificAndAllCommandSameAtTime = errors.New("can't have all cmds and specific cmd at same time") - - // Server errors. - ErrAuth = errors.New("authentication error") - - // CLI errors. - ErrInvalidUserOrPassword = errors.New("user or user information you provided is invalid") - ErrInvalidCommand = errors.New("invalid command") -)