go-sample-api

module
v0.0.0-...-c93e0b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2024 License: MIT

README

go-sample-api

Web api in golang with Gin farmwork:

GO-SAMPLE-API
├───.github                # GitHub-specific files
│   └───workflows          # CI/CD workflows
├───.vscode                # VSCode-specific files and configurations
├───cmd                    # Application entry points
│   └───api                # Main API entry point
│       └───routes         # Route configurations for the HTTP server
├───configs                # Configuration files
├───docs                   # Documentation files
├───internal               # Private application and library code
│   ├───controllers        # HTTP handlers
│   ├───core               # Core business logic
│   │   ├───entities       # Core business entities
│   │   ├───interfaces     # Interfaces for dependencies
│   │       ├───repositories  # Repository interfaces
│   │       └───services      # Service interfaces
│   │  
│   ├───dto                # Data transfer objects (request/response models)
│   └───infra              # Infrastructure implementations
│       ├───databases      # Database access implementations
│       ├───repositories   # Implementations of repository interfaces
│       └───services       # Implementations of service interfaces
├───pkg                    # Public library code
│   └───middlewares        # Custom middleware implementations
├───test                   # Test-related files
└───vendor                 # Third-party dependencies (managed by `go mod`)

Update swagger document

swag init -g cmd/api/main.go

Important command

go mod int <package_name>
go get <package_url>
go mod tidy
go mod vendor
swag init -g cmd/api/main.go

Debug it locally

Please install delve

Click on debugger to run it.

run it

go run cmd/api/main.go

http://localhost:8080/swagger/index.html

image

Directories

Path Synopsis
cmd
api
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
dto
pkg
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL