Skip to content

Commit

Permalink
移除沒有用到的程式碼
Browse files Browse the repository at this point in the history
透過 test coverage 可以看到有一些東西漏測,也有一些東西是多餘的,這裡先
把多餘的東西移掉

看 test coverage 的方法

1. 首先,你得先有測試
2. `go test -coverprofile=some_file`
3. `go tool cover -html=some_file`
  • Loading branch information
Ronmi committed Jul 11, 2016
1 parent e62a741 commit a166211
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions cmd/xchg/types.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package main

import (
"database/sql"

"git.ronmi.tw/ronmi/sdm"
)
import "database/sql"

// Order 代表用戶的外幣資產的變動。
//
Expand Down Expand Up @@ -33,25 +29,3 @@ func initTable(db *sql.DB) error {

return nil
}

func computeOrder(rows *sdm.Rows) (foreign, local, rate float64, err error) {
for rows.Next() {
var data Order
rows.Scan(&data)
foreign += data.Foreign
local += data.Local
}

if foreign > 0 {
rate = local / foreign
}
err = rows.Err()
return
}

// Count 結算某外幣的所有交易
func Count(code string, m *sdm.Manager) (foreign, local, rate float64, err error) {
qstr := `SELECT * FROM orders WHERE currency_code=?`

return computeOrder(m.Query(Order{}, qstr, code))
}

0 comments on commit a166211

Please sign in to comment.