github.com/lianghucheng/zrddz@v0.0.0-20200923083010-c71f680932e2/src/gamedata/reader.go (about) 1 package gamedata 2 3 import ( 4 "github.com/name5566/leaf/log" 5 "github.com/name5566/leaf/recordfile" 6 "reflect" 7 ) 8 9 func readRf(st interface{}) *recordfile.RecordFile { 10 rf, err := recordfile.New(st) 11 if err != nil { 12 log.Fatal("%v", err) 13 } 14 fn := reflect.TypeOf(st).Name() + ".txt" 15 err = rf.Read("gamedata/" + fn) 16 if err != nil { 17 log.Fatal("%v: %v", fn, err) 18 } 19 20 return rf 21 }