删除一些数据收集的测试方法
This commit is contained in:
parent
7a5531440d
commit
2514af413e
24
.vscode/settings.json
vendored
Normal file
24
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"editor.tokenColorCustomizations": {
|
||||
"textMateRules": [
|
||||
{
|
||||
"scope": "googletest.failed",
|
||||
"settings": {
|
||||
"foreground": "#f00"
|
||||
}
|
||||
},
|
||||
{
|
||||
"scope": "googletest.passed",
|
||||
"settings": {
|
||||
"foreground": "#0f0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"scope": "googletest.run",
|
||||
"settings": {
|
||||
"foreground": "#0f0"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
6
base.go
6
base.go
|
@ -135,16 +135,20 @@ func SaveGob(fname string, datatype reflect.Type, kfs ...KeyKind) {
|
|||
|
||||
// LoadGob load gob from file
|
||||
func LoadGob(fname string, v IKeyList) {
|
||||
|
||||
f, err := os.Open(fname)
|
||||
log.Println("load data: ", fname)
|
||||
CheckErrorPanic(err)
|
||||
reader := flate.NewReader(f)
|
||||
dec := gob.NewDecoder(reader)
|
||||
dec.Decode(v)
|
||||
|
||||
}
|
||||
|
||||
// GetRandomKey get ikeylist key by random
|
||||
func GetRandomKey(v IKeyList) interface{} {
|
||||
return v.GetKeys()[rand.Intn(v.GetLength())]
|
||||
ret := v.GetKeys()[rand.Intn(v.GetLength())]
|
||||
return ret
|
||||
}
|
||||
|
||||
// GetRandomKeyBySlice get ikeylist key by random
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
var buildinglist = &KeyList{}
|
||||
|
||||
func init() {
|
||||
LoadGob("./data/building.gob", buildinglist)
|
||||
// LoadGob("./data/building.gob", buildinglist)
|
||||
}
|
||||
|
||||
// UnimplementedBuildingServer can be embedded to have forward compatible implementations.
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestMakeBuildingGob(t *testing.T) {
|
||||
func estMakeBuildingGob(t *testing.T) {
|
||||
f, err := os.Open("/home/eson/test/spider_xingming/building_simple.txt")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
// SaveData("./data/lastname-test.gob", nln)
|
||||
// }
|
||||
|
||||
func TestS(t *testing.T) {
|
||||
func estS(t *testing.T) {
|
||||
gob.Register(Country{})
|
||||
ln := &KeyList{}
|
||||
LoadGob("./data/lastname1.gob", ln)
|
||||
|
@ -36,7 +36,7 @@ func TestS(t *testing.T) {
|
|||
f.Write(country.Pic)
|
||||
}
|
||||
|
||||
func TestReadData(t *testing.T) {
|
||||
func estReadData(t *testing.T) {
|
||||
gob.Register(Country{})
|
||||
ln := &KeyList{}
|
||||
LoadGob("./data/country.gob", ln)
|
||||
|
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
context "context"
|
||||
"encoding/gob"
|
||||
)
|
||||
|
||||
// Country struct
|
||||
|
@ -13,11 +12,6 @@ type Country struct {
|
|||
|
||||
var countrylist *KeyList = &KeyList{}
|
||||
|
||||
func init() {
|
||||
gob.Register(Country{})
|
||||
LoadGob("./data/country.gob", countrylist)
|
||||
}
|
||||
|
||||
type countryserver struct {
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func testRemakeGob(t *testing.T) {
|
||||
func estRemakeGob(t *testing.T) {
|
||||
country := &KeyList{}
|
||||
LoadGob("./data/country-fix.gob", country)
|
||||
// for i, ikey := range country.Keys {
|
||||
|
|
1
go.mod
1
go.mod
|
@ -4,6 +4,7 @@ go 1.14
|
|||
|
||||
require (
|
||||
github.com/474420502/hunter v0.1.1
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
|
||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
|
||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
|
||||
|
|
13
main.go
13
main.go
|
@ -17,8 +17,10 @@ var cl *KeyList = &KeyList{}
|
|||
func init() {
|
||||
|
||||
gob.Register(KeyList{})
|
||||
|
||||
gob.Register(Country{})
|
||||
gob.Register(LastName{})
|
||||
gob.Register(FirstName{})
|
||||
gob.Register(NameCode{})
|
||||
|
||||
f, err := os.OpenFile("./my.log", os.O_CREATE|os.O_RDWR, os.ModePerm)
|
||||
CheckErrorPanic(err)
|
||||
|
@ -26,6 +28,14 @@ func init() {
|
|||
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
LoadGob("./data/building.gob", buildinglist)
|
||||
LoadGob("./data/country.gob", countrylist)
|
||||
|
||||
LoadGob("./data/firstname.gob", fnl)
|
||||
LoadGob("./data/lastname.gob", lnl)
|
||||
|
||||
LoadGob("./data/province.gob", province)
|
||||
LoadGob("./data/ways.gob", ways)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -43,6 +53,7 @@ func main() {
|
|||
RegisterWayHandlerServer(ctx, mux, &wayserver{})
|
||||
RegisterBuildingHandlerServer(ctx, mux, &buildingserver{})
|
||||
|
||||
log.Println("Listen 4433")
|
||||
log.Fatal(http.ListenAndServe(":4433", mux))
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
@ -17,14 +16,6 @@ type FirstName struct {
|
|||
var fnl *KeyList = &KeyList{}
|
||||
var lnl *KeyList = &KeyList{}
|
||||
|
||||
func init() {
|
||||
gob.Register(LastName{})
|
||||
gob.Register(FirstName{})
|
||||
|
||||
LoadGob("./data/firstname.gob", fnl)
|
||||
LoadGob("./data/lastname.gob", lnl)
|
||||
}
|
||||
|
||||
type nameserver struct {
|
||||
}
|
||||
|
||||
|
@ -33,6 +24,7 @@ func (s *nameserver) FirstName(cxt context.Context, request *Request) (*Reply, e
|
|||
reply := &Reply{}
|
||||
reply.Message = string(GetRandomKey(fnl).(FirstName).Name)
|
||||
return reply, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *nameserver) LastName(cxt context.Context, request *Request) (*Reply, error) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
context "context"
|
||||
"encoding/gob"
|
||||
)
|
||||
|
||||
// NameCode 省份地区的结构
|
||||
|
@ -14,11 +13,6 @@ type NameCode struct {
|
|||
|
||||
var province = &KeyList{}
|
||||
|
||||
func init() {
|
||||
gob.Register(NameCode{})
|
||||
LoadGob("./data/province.gob", province)
|
||||
}
|
||||
|
||||
type provinceserver struct {
|
||||
}
|
||||
|
||||
|
|
10
readme.md
Normal file
10
readme.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# 编译流程
|
||||
|
||||
* sh generate.sh
|
||||
* git submodule init
|
||||
* git submodule update
|
||||
* go build
|
||||
|
||||
## 执行流程
|
||||
|
||||
* ./workshop
|
4
way.go
4
way.go
|
@ -6,10 +6,6 @@ import (
|
|||
|
||||
var ways = &KeyList{}
|
||||
|
||||
func init() {
|
||||
LoadGob("./data/ways.gob", ways)
|
||||
}
|
||||
|
||||
// wayserver can be embedded to have forward compatible implementations.
|
||||
type wayserver struct {
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/qedus/osmpbf"
|
||||
)
|
||||
|
||||
func testPBF(t *testing.T) {
|
||||
func estPBF(t *testing.T) {
|
||||
f, err := os.Open("/home/eson/tools/china-latest.osm.pbf")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue
Block a user