Skip to content

Commit

Permalink
Merge pull request #14 from lospejos/main
Browse files Browse the repository at this point in the history
Bumped Go version to 1.21
  • Loading branch information
koddr committed Oct 13, 2023
2 parents 931182f + 6d0cd7f commit 5319f46
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 85 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18-alpine AS builder
FROM golang:1.21-alpine AS builder

# Move to working directory (/build).
WORKDIR /build
Expand All @@ -23,4 +23,4 @@ COPY --from=builder ["/build/apiserver", "/build/.env", "/"]
EXPOSE 5000

# Command to run when starting the container.
ENTRYPOINT ["/apiserver"]
ENTRYPOINT ["/apiserver"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@ And, of course, you can support me by donating at [LiberaPay](https://liberapay.
## ⚠️ License

MIT © [Vic Shóstak](https://github.com/koddr) & [True web artisans](https://1wa.co/).


## Building:

https://levelup.gitconnected.com/a-better-way-than-ldflags-to-add-a-build-version-to-your-go-binaries-2258ce419d2d



Windows:
```
$ set CGO_ENABLED=0 && go build -ldflags="-w -s -X 'main.version=1.0.1'" .
```
10 changes: 5 additions & 5 deletions app/controllers/book_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func CreateBook(c *fiber.Ctx) error {
// Set expiration time from JWT data of current book.
expires := claims.Expires

// Checking, if now time greather than expiration from JWT.
// Checking, if now time greater than expiration from JWT.
if now > expires {
// Return status 401 and unauthorized error message.
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
Expand Down Expand Up @@ -223,7 +223,7 @@ func UpdateBook(c *fiber.Ctx) error {
// Set expiration time from JWT data of current book.
expires := claims.Expires

// Checking, if now time greather than expiration from JWT.
// Checking, if now time greater than expiration from JWT.
if now > expires {
// Return status 401 and unauthorized error message.
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
Expand Down Expand Up @@ -254,7 +254,7 @@ func UpdateBook(c *fiber.Ctx) error {
})
}

// Checking, if book with given ID is exists.
// Checking, if book with given ID does exist.
foundedBook, err := db.GetBook(book.ID)
if err != nil {
// Return status 404 and book not found error.
Expand Down Expand Up @@ -319,7 +319,7 @@ func DeleteBook(c *fiber.Ctx) error {
// Set expiration time from JWT data of current book.
expires := claims.Expires

// Checking, if now time greather than expiration from JWT.
// Checking, if now time greater than expiration from JWT.
if now > expires {
// Return status 401 and unauthorized error message.
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
Expand Down Expand Up @@ -362,7 +362,7 @@ func DeleteBook(c *fiber.Ctx) error {
})
}

// Checking, if book with given ID is exists.
// Checking, if book with given ID does exist.
foundedBook, err := db.GetBook(book.ID)
if err != nil {
// Return status 404 and book not found error.
Expand Down
2 changes: 1 addition & 1 deletion app/models/book_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type BookAttrs struct {

// Value make the BookAttrs struct implement the driver.Valuer interface.
// This method simply returns the JSON-encoded representation of the struct.
func (b BookAttrs) Value() (driver.Value, error) {
func (b *BookAttrs) Value() (driver.Value, error) {
return json.Marshal(b)
}

Expand Down
51 changes: 26 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
module github.com/koddr/tutorial-go-fiber-rest-api

go 1.18
go 1.21

require (
github.com/arsmn/fiber-swagger/v2 v2.31.1
github.com/go-playground/validator/v10 v10.10.1
github.com/go-playground/validator/v10 v10.15.5
github.com/gofiber/fiber/v2 v2.49.2
github.com/gofiber/jwt/v2 v2.2.7
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.3.1
github.com/jackc/pgx/v4 v4.15.0
github.com/jackc/pgx/v4 v4.18.1
github.com/jmoiron/sqlx v1.3.5
github.com/joho/godotenv v1.4.0
github.com/stretchr/testify v1.7.0
github.com/swaggo/swag v1.8.1
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.8.4
github.com/swaggo/swag v1.16.2
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.11.0 // indirect
github.com/jackc/pgconn v1.14.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.2.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.10.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/swaggo/files v1.0.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.49.0 // indirect
github.com/valyala/fasthttp v1.50.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
golang.org/x/tools v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 5319f46

Please sign in to comment.