Skip to content

Instantly share code, notes, and snippets.

@chespinoza
Created July 24, 2013 21:37
Show Gist options
  • Save chespinoza/6074810 to your computer and use it in GitHub Desktop.
Save chespinoza/6074810 to your computer and use it in GitHub Desktop.
io2int test
package main
import (
"bufio"
"fmt"
"strconv"
"strings"
)
func main() {
str := []byte("L=312\r\n")
reader := bufio.NewReader(strings.NewReader(string(str)))
line, _ := reader.ReadString('\n')
if line[:1] == "L" {
l, err := strconv.Atoi(strings.TrimSpace(line[2:]))
if err != nil {
fmt.Println(err)
} else {
fmt.Println(l)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment