Fixes go fmt

This commit is contained in:
cornelk
2017-02-01 15:57:07 +07:00
parent 7ba0cdaf53
commit 7e1874a5b3
2 changed files with 23 additions and 24 deletions

View File

@@ -1,4 +1,3 @@
package main
const (
@@ -9,16 +8,16 @@ const (
var Orders []*Order
type Order struct {
OrderID int
OrderID int
Exchange string
Type int
Amount float64
Price float64
Type int
Amount float64
Price float64
}
func NewOrder(Exchange string, amount, price float64) (int) {
func NewOrder(Exchange string, amount, price float64) int {
order := &Order{}
if (len(Orders) == 0) {
if len(Orders) == 0 {
order.OrderID = 0
} else {
order.OrderID = len(Orders)
@@ -31,7 +30,7 @@ func NewOrder(Exchange string, amount, price float64) (int) {
return order.OrderID
}
func DeleteOrder(orderID int) (bool) {
func DeleteOrder(orderID int) bool {
for i := range Orders {
if Orders[i].OrderID == orderID {
Orders = append(Orders[:i], Orders[i+1:]...)
@@ -61,4 +60,4 @@ func GetOrderByOrderID(orderID int) (*Order, bool) {
}
}
return nil, false
}
}

View File

@@ -1,23 +1,23 @@
package main
import (
"log"
"net/http"
"time"
"log"
"net/http"
"time"
)
func Logger(inner http.Handler, name string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
inner.ServeHTTP(w, r)
inner.ServeHTTP(w, r)
log.Printf(
"%s\t%s\t%s\t%s",
r.Method,
r.RequestURI,
name,
time.Since(start),
)
})
}
log.Printf(
"%s\t%s\t%s\t%s",
r.Method,
r.RequestURI,
name,
time.Since(start),
)
})
}