points/points.go
func ParseText(line string) (*Points, error) {

	row := strings.Split(strings.Trim(line, "\n \t\r"), " ")
	if len(row) != 3 {
		return nil, fmt.Errorf("bad message: %#v", line)
	}

	// 0x2e == ".". Or use split? @TODO: benchmark
	// if strings.Contains(row[0], "..") || row[0][0] == 0x2e || row[0][len(row)-1] == 0x2e {
	// 	return nil, fmt.Errorf("bad message: %#v", line)
	// }

	value, err := strconv.ParseFloat(row[1], 64)

	if err != nil || math.IsNaN(value) {
		return nil, fmt.Errorf("bad message: %#v", line)
	}

	tsf, err := strconv.ParseFloat(row[2], 64)

	if err != nil || math.IsNaN(tsf) {
		return nil, fmt.Errorf("bad message: %#v", line)
	}

	// 315522000 == "1980-01-01 00:00:00"
	// if tsf < 315532800 {
	// 	return nil, fmt.Errorf("bad message: %#v", line)
	// }

	// 4102444800 = "2100-01-01 00:00:00"
	// Hello people from the future
	// if tsf > 4102444800 {
	// 	return nil, fmt.Errorf("bad message: %#v", line)
	// }

	return OnePoint(row[0], value, int64(tsf)), nil
}
func ParseText(line string) (*Points, error) {

	row := strings.Split(strings.Trim(line, "\n \t\r"), " ")
	if len(row) != 3 {
		return nil, fmt.Errorf("bad message: %#v", line)
	}

	// 0x2e == ".". Or use split? @TODO: benchmark
	// if strings.Contains(row[0], "..") || row[0][0] == 0x2e || row[0][len(row)-1] == 0x2e {
	// 	return nil, fmt.Errorf("bad message: %#v", line)
	// }

	value, err := strconv.ParseFloat(row[1], 64)

	if err != nil || math.IsNaN(value) {
		return nil, fmt.Errorf("bad message: %#v", line)
	}

	tsf, err := strconv.ParseFloat(row[2], 64)

	if err != nil || math.IsNaN(tsf) {
		return nil, fmt.Errorf("bad message: %#v", line)
	}

	// 315522000 == "1980-01-01 00:00:00"
	// if tsf < 315532800 {
	// 	return nil, fmt.Errorf("bad message: %#v", line)
	// }

	// 4102444800 = "2100-01-01 00:00:00"
	// Hello people from the future
	// if tsf > 4102444800 {
	// 	return nil, fmt.Errorf("bad message: %#v", line)
	// }

	return OnePoint(row[0], value, int64(tsf)), nil
}
func ParseText ( line string ) ( * Points , error ) { row := strings . Split ( strings . Trim ( line , " \n \t \r " ) , " " ) if len ( row ) != 3 { return nil , fmt . Errorf ( " " , line ) } // 0x2e == ".". Or use split? @TODO: benchmark // if strings.Contains(row[0], "..") || row[0][0] == 0x2e || row[0][len(row)-1] == 0x2e { // 	return nil, fmt.Errorf("bad message: %#v", line) // } value , err := strconv . ParseFloat ( row [ 1 ] , 64 ) if err != nil || math . IsNaN ( value ) { return nil , fmt . Errorf ( " " , line ) } tsf , err := strconv . ParseFloat ( row [ 2 ] , 64 ) if err != nil || math . IsNaN ( tsf ) { return nil , fmt . Errorf ( " " , line ) } // 315522000 == "1980-01-01 00:00:00" // if tsf < 315532800 { // 	return nil, fmt.Errorf("bad message: %#v", line) // } // 4102444800 = "2100-01-01 00:00:00" // Hello people from the future // if tsf > 4102444800 { // 	return nil, fmt.Errorf("bad message: %#v", line) // } return OnePoint ( row [ 0 ] , value , int64 ( tsf ) ) , nil }
// ParseText parse text protocol Point
//  host.Point.value 42 1422641531\n
ParseText parse text protocol Point host . Point . value 42 1422641531 \ n