This project allows you to create a basic device management application using Go (Golang). The application can be used to register, update, delete, and view devices.
- Go (Golang) should be installed.
- Gorm and Gin libraries should be installed.
-
Clone this repository to your local directory.
git clone https://github.com/muzeyr/go-lang-api-example
-
Navigate to the project directory.
cd go-lang-api-example
-
Create the SQLite database.
touch test.sqlite
-
Start the application.
go run main.go
-
The application should now be running at http://localhost:8088.
GET /devices
: To view all devices.GET /devices/:id
: To view a specific device by ID.POST /devices
: To create a new device.PATCH /devices/:id
: To update a specific device.
curl http://localhost:8088/devices
curl http://localhost:8088/devices/1
curl -X POST -H "Content-Type: application/json" -d '{"title": "New Device"}' http://localhost:8088/devices
curl -X PATCH -H "Content-Type: application/json" -d '{"title": "Updated Device"}' http://localhost:8088/devices/1