- GOLANG
- MONGODB
- REST
- MVC
$ go mod init rest_go_mongo
$ go get -u github.com/globalsign/mgo
$ go get -u github.com/gorilla/mux
// (A powerful HTTP router and URL matcher for building Go web servers with)
- raiz:
- main.go
- config/config.go
- api/app/handler/common.go
- api/app/handler/employess.go
- api/app/handler/mgodao.go
- api/app/model/model.go (vamos mudar para Employes)
GET => http://localhost:8000/employess
POST => http://localhost:8000/employees
A GOROOT é uma variável de ambiente que especifica o local da instalação do go e pode ser definido como C: \ Go
A GOPATH é uma variável de ambiente que especifica o local do seu espaço de trabalho.
Se a GOPATH não estiver definido, presume-se que esteja $HOME/go nos sistemas Unix e %USERPROFILE%\go no Windows.
Crie a variável de ambiente GOPATH e faça referência ao caminho do espaço de trabalho
$ go version
//go version go1.12 windows/amd64
/* Fenced code */
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
$ go run hello-world.go
// nome do objeto
$ go build hello-world.go
$ ls
// hello-world hello-world.go
$ ./hello-world
// hello world
type Employee struct {
_id bson.ObjectId `bson:"_id,omitempty"`
Name string `json:"name"`
City string `json:"city"`
Age int `json:"age"`
Status bool `json:"status"`
}
go run main.go
Axel Alexander
- axel - my site
- **Axel Alexander ** - web site - contact and contracts
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details