I need help, I've got 3 numbers from a string, which i need to do calculations with, but i dont know how to use them.
This is what i've got:
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
)
var afstand int
var tijd int
var Snelheid int
func main() {
file, ferr := os.Open("DataG.txt")
if ferr != nil {
panic(file)
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanWords)
for scanner.Scan() {
re := regexp.MustCompile("[0-9]+")
re.FindAllString(scanner.Text(), 2)
strconv.Atoi(scanner.Text())
if s, err := strconv.Atoi(scanner.Text()); err == nil {
fmt.Printf("%v \n", s)
}
}
}
And this is the result:
PS C:\Users\Home> go run gebouwen.go
100
150
80
Now my problem is that i dont know how to use these numbers for math.