diff --git a/Makefile b/Makefile index 0019a44..70d28a2 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ test: .PHONY: lint lint: - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest golangci-lint run ./... .PHONY: govulncheck diff --git a/hacks/hacks.go b/hacks/hacks.go index a350bfc..ef158b8 100644 --- a/hacks/hacks.go +++ b/hacks/hacks.go @@ -1,45 +1,46 @@ package main -import ( - "bufio" - "github.com/puni9869/pinmyblogs/pkg/logger" - "net" - "strings" - "time" -) - -const PORT = "6652" - -func main() { - log := logger.NewLogger() - var err error - l, err := net.Listen("tcp", ":"+PORT) - if err != nil { - log.WithError(err).Error("failed to listen.") - return - } - defer l.Close() - - c, err := l.Accept() - if err != nil { - log.WithError(err).Error("failed to accept the connection request.") - return - } - for { - netData, err := bufio.NewReader(c).ReadString(byte('\n')) - if err != nil { - log.WithError(err).Error("failed to get data from stream.") - return - } - if strings.TrimSpace(string(netData)) == "STOP" { - c.Write([]byte("BYE...")) - return - } - - log.Infof("-> %s", string(netData)) - t := time.Now() - myTime := t.Format(time.RFC1123Z) + "\n" - - c.Write([]byte(myTime)) - } -} +// +//import ( +// "bufio" +// "github.com/puni9869/pinmyblogs/pkg/logger" +// "net" +// "strings" +// "time" +//) +// +//const PORT = "6652" +// +//func main() { +// log := logger.NewLogger() +// var err error +// l, err := net.Listen("tcp", ":"+PORT) +// if err != nil { +// log.WithError(err).Error("failed to listen.") +// return +// } +// defer l.Close() +// +// c, err := l.Accept() +// if err != nil { +// log.WithError(err).Error("failed to accept the connection request.") +// return +// } +// for { +// netData, err := bufio.NewReader(c).ReadString(byte('\n')) +// if err != nil { +// log.WithError(err).Error("failed to get data from stream.") +// return +// } +// if strings.TrimSpace(string(netData)) == "STOP" { +// c.Write([]byte("BYE...")) +// return +// } +// +// log.Infof("-> %s", string(netData)) +// t := time.Now() +// myTime := t.Format(time.RFC1123Z) + "\n" +// +// c.Write([]byte(myTime)) +// } +//} diff --git a/models/user.go b/models/user.go index e621e5f..7aa8ab7 100644 --- a/models/user.go +++ b/models/user.go @@ -25,5 +25,5 @@ type User struct { } func (u User) Format(f fmt.State, verb rune) { - f.Write([]byte(fmt.Sprintf("Email: %s FirstName: %s Id: %s", u.Email, u.FirstName, u.ID))) + _, _ = f.Write([]byte(fmt.Sprintf("Email: %s FirstName: %s Id: %s", u.Email, u.FirstName, u.ID))) } diff --git a/pkg/cache/main.go b/pkg/cache/main.go index 0204727..d638f98 100644 --- a/pkg/cache/main.go +++ b/pkg/cache/main.go @@ -1,45 +1,46 @@ package cache -import ( - "bufio" - "github.com/puni9869/pinmyblogs/pkg/logger" - "net" - "strings" - "time" -) - -const PORT = "8080" - -func main() { - log := logger.NewLogger() - var err error - l, err := net.Listen("tcp", "127.0.0.1:"+PORT) - if err != nil { - log.WithError(err).Error("failed to listen.") - return - } - defer l.Close() - - c, err := l.Accept() - if err != nil { - log.WithError(err).Error("failed to accept the connection request.") - return - } - for { - netData, err := bufio.NewReader(c).ReadString(byte('\n')) - if err != nil { - log.WithError(err).Error("failed to get data from stream.") - return - } - if strings.TrimSpace(string(netData)) == "STOP" { - c.Write([]byte("BYE...")) - return - } - - log.Infof("-> %s", string(netData)) - t := time.Now() - myTime := t.Format(time.RFC1123Z) + "\n" - - c.Write([]byte(myTime)) - } -} +// +//import ( +// "bufio" +// "github.com/puni9869/pinmyblogs/pkg/logger" +// "net" +// "strings" +// "time" +//) +// +//const PORT = "8080" +// +//func main() { +// log := logger.NewLogger() +// var err error +// l, err := net.Listen("tcp", "127.0.0.1:"+PORT) +// if err != nil { +// log.WithError(err).Error("failed to listen.") +// return +// } +// defer l.Close() +// +// c, err := l.Accept() +// if err != nil { +// log.WithError(err).Error("failed to accept the connection request.") +// return +// } +// for { +// netData, err := bufio.NewReader(c).ReadString(byte('\n')) +// if err != nil { +// log.WithError(err).Error("failed to get data from stream.") +// return +// } +// if strings.TrimSpace(string(netData)) == "STOP" { +// c.Write([]byte("BYE...")) +// return +// } +// +// log.Infof("-> %s", string(netData)) +// t := time.Now() +// myTime := t.Format(time.RFC1123Z) + "\n" +// +// c.Write([]byte(myTime)) +// } +//} diff --git a/server/setting/setting.go b/server/setting/setting.go index 66bfcd2..0e5702a 100644 --- a/server/setting/setting.go +++ b/server/setting/setting.go @@ -2,13 +2,14 @@ package setting import ( "fmt" + "net/http" + "slices" + "strings" + "github.com/puni9869/pinmyblogs/models" "github.com/puni9869/pinmyblogs/pkg/config" "github.com/puni9869/pinmyblogs/pkg/database" "github.com/puni9869/pinmyblogs/pkg/logger" - "net/http" - "slices" - "strings" "github.com/gin-contrib/sessions" "github.com/puni9869/pinmyblogs/server/middlewares" @@ -76,7 +77,7 @@ func DownloadMyData(c *gin.Context) { if !slices.Contains([]string{"csv", "json", "html"}, format) { format = "json" } - + log.Infof("generating the data in %s format", format) session := sessions.Default(c) currentlyLoggedIn := session.Get(middlewares.Userkey)