Code Monkey home page Code Monkey logo

go-app's Introduction

Install Go-App Application

This project provides a best practice way to build application using Go.

Prerequisites

After installing the application:

Note: After installing the application, you need to download all necessary dependency which application requires:

  • Run the following command: go mod download or go mod tidy

Create migration

  • After successfully installed migration, let's create migration using command: migrate create -seq -ext .sql -dir internal/migrations create_example_table

  • If there were no errors, we should have two files available under internal/migrations folder:

    • 000001_create_example_table.down.sql
    • 000001_example_users_table.up.sql

Run migration

  • To run migration, let's use command: migrate -database ${POSTGRESQL_URL} -path db/migrations up

  • When using Migrate CLI we need to pass to database URL. Let's export it to a variable for convenience: export POSTGRESQL_URL='postgres://username:password@localhost:5432/database_name?sslmode=disable'

  • During migration running if error occurred which tells, Dirty database version <version>. Fix and force version. In that case, run command: migrate -path migrations/ -database postgres://test:test@localhost/dummy?sslmode=disable force <version>

Drop migration

Note: Please note that before drop migration you need to export convenience variable.

  • Drop all migration using command: migrate -database ${POSTGRESQL_URL} -path db/migrations down

Environment Variables

The following environment variables are required to run the application:

Variable Description Default Value
DB_PORT Port of the database server (Set as an environment variable)
DB_HOST Hostname or IP address of the database server (Set as an environment variable)
DB_USER Username for the database user (Set as an environment variable)
DB_PASSWORD Password for the database user (Set as an environment variable)
DB_NAME Name of the database (Set as an environment variable)

Note: Do not store the actual password in this file. Instead, set the password as an environment variable before running the container using methods specific to your operating system. For example, on Linux or macOS, you can use the export command:

Updating Swagger Documentation

Note: If you're making changes to the code that affect the Swagger documentation, you can regenerate it using the following command.

  • Run the following command: swag init --parseDependency --parseInternal -g main.go

go-app's People

Contributors

nicolas-ggd avatar

Watchers

 avatar

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.