Created
May 13, 2018 04:50
-
-
Save g14a/a95d1df82db9e6a506236b3f387bb9f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
data := "*ZJ,2030295062,V1,113057,A,3029.7113,N,7711.408,E,21.95,41.95,120518,00000000#" | |
p := &Packet{} | |
parse(data, p) | |
} | |
type Packet struct { | |
deviceID string | |
time string | |
latitude string | |
longitude string | |
speed string | |
angle string | |
date string | |
status string | |
} | |
func parse(data string, p Packet) { | |
s := strings.Split(data, ",") | |
fmt.Println(s) | |
p.deviceID = s[1] | |
p.time = s[3] | |
p.latitude = s[5] | |
p.longitude = s[7] | |
p.speed = s[9] | |
p.angle = s[10] | |
p.date = s[11] | |
p.status = s[12] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment