An open API service indexing awesome lists of open source software.

https://github.com/webcyou/go_api_sample

The Go Programming Language - API sample
https://github.com/webcyou/go_api_sample

Last synced: 10 months ago
JSON representation

The Go Programming Language - API sample

Awesome Lists containing this project

README

          

# Go Language - API sample

## Web Framework

[Gin Web Framework](https://github.com/gin-gonic/gin)

```
go get gopkg.in/gin-gonic/gin.v1
```

## ORM library

[GORM](https://github.com/jinzhu/gorm)

```
go get -u github.com/jinzhu/gorm
```

## API

Hello world!
```$xslt
http://localhost:8080/
```

All Users
```
http://localhost:8080/users/
```

### Example

```$xslt
{
"users": [
{
"id": 1,
"name": "ユーザー1",
"items": [
{
"id": 1,
"name": "ゲーム1",
"score": 5,
"user_id": 1
},
{
"id": 2,
"name": "ゲーム2",
"score": 0,
"user_id": 1
},
... {
]
},
{
"id": 2,
"name": "ユーザー1",
"items": [
{
"id": 9,
"name": "ゲーム3",
"score": 1,
"user_id": 2
},
...
]
},
...
]
}
```

User & MatchingUsers
```
http://localhost:8080/users/:id
```

### Example

```
{
"user": {
"id": 2,
"name": "ユーザー2",
"items": [
{
"id": 9,
"name": "ゲーム1",
"score": 1,
"user_id": 2
},
{
"id": 10,
"name": "ゲーム2",
"score": 1,
"user_id": 2
},
{
"id": 11,
"name": "ゲーム3",
"score": 3,
"user_id": 2
},
...
]
},
"matching_users": [
{
"id": 1,
"name": "ユーザー1",
"score": 0.10886898139200682
},
{
"id": 9,
"name": "ユーザー9",
"score": 0.1
},
{
"id": 7,
"name": "ユーザー7",
"score": 0.08462632608958592
},
{
"id": 4,
"name": "ユーザー4",
"score": 0.08270931562630669
},
...
]
}
```

## Algorithm
The basic scoring algorithm is Euclidean distance

```math
d(p,q)=d(q,p)=\sqrt{(q_1-p_1)^2+(q_2-p_2)^2+\cdots+(q_n+p_n)^2}
```

## Author

**Daisuke Takayama**
* [@webcyou](https://twitter.com/webcyou)
* [@panicdragon](https://twitter.com/panicdragon)
*
*
*