Giter Club home page Giter Club logo

crud-golang's Introduction

Rest API em GOLANG

🚀 Projeto de estudo sobre a liguagem Go com uma API Rest e banco de dados MySQL

Para rodar o projeto

🏁 Criando a tabela do Projeto

CREATE TABLE Persons (
    id int NOT NULL AUTO_INCREMENT,
    name varchar(50) NOT NULL,
    email varchar(100),
    PRIMARY KEY (id)
);

🎲 Rodando o Back End (servidor)

# Clone este repositório
$ git clone <https://github.com/bahcasac/CRUD-GOLANG.git>

# Acesse a pasta raiz do projeto
$ cd CRUD-GOLANG

# Configurando o seu ambiente
$ cp .env.sample .env

# Rode o comando de execução no arquivo `main.go`
$ go run main.go

# O servidor inciará na porta:5001 - acesse <http://localhost:5001>

🎉 Consumindo a API

# Criar um usuário
curl --location --request POST 'http://localhost:5001/users' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name":"Maria",
    "email":"[email protected]"
}'

# Listagem de usuários
curl --location --request GET 'http://localhost:5001/users'

#  Listar usuário por id
curl --location --request GET 'http://localhost:5001/users/1'

# Atualizar um usuário
curl --location --request PUT 'http://localhost:5001/users/1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name":"jose",
    "email":"[email protected]"
}'

# Apagar um usuário
curl --location --request DELETE 'http://localhost:5001/users/1'

crud-golang's People

Contributors

bahokubo 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.