Giter Club home page Giter Club logo

go-rest-api's Introduction

Golang Gin Framework Fundamental

Example golang using gin framework everything you need, i create this tutorial special for beginner.

Feature

  • Containerize Application Using Docker
  • Protected Route Using JWT
  • Integerasi ORM Database Using Gorm
  • API Documentation Using Swagger
  • Validation Request Using Go Playground Validator
  • Integerasi Unit Testing
  • And More

Command

  • Application Lifecycle

    • Install node modules
    $ go get . || go mod || make goinstall
    • Build application
    $ go build -o main || make goprod
    • Start application in development
    $ go run main.go | make godev
    • Test application
    $ go test main.go main_test.go || make gotest
  • Docker Lifecycle

    • Build container
    $ docker-compose build | make dcb
    • Run container with flags
    $ docker-compose up -d --<flags name> | make dcu f=<flags name>
    • Run container build with flags
    $ docker-compose up -d --build --<flags name> | make dcubf f=<flags name>
    • Run container
    $ docker-compose up -d --build | make dcu
    • Stop container
    $ docker-compose down | make dcd

Author

go-rest-api's People

Contributors

restuwahyu13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-rest-api's Issues

[README]

Hello, Can you please add more details into readme file.
My application is up and running connecting to database. What is the home page to bring up the application?
How to see the swagger documentation?
What is the home page for this application?
Which JWT token to be used or generated to call the apis
/api/v1/student gives me error.

Pleae update the documentation. It will be helpful for users like me.

Why we used channel here instead of string/error type

I saw this kind of uses at many places. Please help me to understand this

`func (r *repository) RegisterRepository(input *model.EntityUsers) (*model.EntityUsers, string) {

var users model.EntityUsers
db := r.db.Model(&users)
errorCode := make(chan string, 1)

checkUserAccount := db.Debug().Select("*").Where("email = ?", input.Email).Find(&users)

if checkUserAccount.RowsAffected > 0 {
	errorCode <- "REGISTER_CONFLICT_409"
	return &users, <-errorCode
} `

Dockerfile is missing module and depends for project

`=> ERROR [builder 12/12] RUN go build -o main . 6.2s

[builder 12/12] RUN go build -o main .:
0.407 go: downloading github.com/gin-gonic/gin v1.7.1
0.409 go: downloading github.com/gin-contrib/gzip v0.0.3
0.409 go: downloading github.com/gin-contrib/cors v1.3.1
0.411 go: downloading github.com/danielkov/gin-helmet v0.0.0-20171108135313-1387e224435e
0.530 go: downloading github.com/sirupsen/logrus v1.8.1
0.541 go: downloading gorm.io/driver/postgres v1.5.6
0.572 go: downloading gorm.io/gorm v1.25.7
0.637 go: downloading github.com/dgrijalva/jwt-go v3.2.0+incompatible
0.637 go: downloading github.com/go-playground/validator/v10 v10.5.0
0.674 go: downloading github.com/joho/godotenv v1.3.0
0.709 go: downloading github.com/restuwahyu13/go-playground-converter v0.0.5
0.715 go: downloading github.com/sendgrid/sendgrid-go v3.8.0+incompatible
0.736 go: downloading golang.org/x/crypto v0.14.0
0.845 go: downloading github.com/google/uuid v1.2.0
0.879 go: downloading github.com/jackc/pgx/v5 v5.4.3
1.354 go: downloading github.com/gin-contrib/sse v0.1.0
1.371 go: downloading github.com/jinzhu/now v1.1.5
1.395 go: downloading github.com/go-playground/universal-translator v0.17.0
1.399 go: downloading github.com/leodido/go-urn v1.2.1
1.459 go: downloading golang.org/x/text v0.13.0
1.500 go: downloading github.com/jackc/pgpassfile v1.0.0
1.511 go: downloading github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a
1.765 go: downloading github.com/jinzhu/inflection v1.0.0
1.776 go: downloading github.com/golang/protobuf v1.5.2
2.008 go: downloading github.com/ugorji/go/codec v1.2.5
2.261 go: downloading gopkg.in/yaml.v2 v2.4.0
2.516 go: downloading github.com/ugorji/go v1.2.5
2.621 go: downloading github.com/go-playground/locales v0.13.0
2.753 go: downloading google.golang.org/protobuf v1.26.0
5.989 /go/pkg/mod/github.com/mattn/[email protected]/isatty_tcgets.go:6:8: missing go.sum entry for module providing package golang.org/x/sys/unix (imported by github.com/mattn/go-isatty); to add:
5.989 go get github.com/mattn/[email protected]
5.989 /go/pkg/mod/github.com/sendgrid/[email protected]+incompatible/rest.go:10:2: missing go.sum entry for module providing package golang.org/x/net/context (imported by github.com/sendgrid/rest); to add:
5.989 go get github.com/sendgrid/[email protected]+incompatible


Dockerfile:35

33 | CGO_ENABLED="0"
34 |
35 | >>> RUN go build -o main .
36 |
37 | # Final Stage

ERROR: failed to solve: process "/bin/sh -c go build -o main ." did not complete successfully: exit code: 1`

Question about style of coding

Hi. I was wondering if there is a reason why you handled return values most of the times using channels? Is this a best practice or personal preference?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.