Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

33 lines
612 B

package main
import (
"fmt"
"strings"
)
func main() {
hdr := []string{"empid", "employee", "address", "hours worked",
"hourly rate", "manager"}
csvHdrCol(hdr)
hdr2 := []string{"employee", "empid", "hours worked", "address",
"manager", "hourly rate"}
csvHdrCol(hdr2)
}
func csvHdrCol(header []string) {
csvHeadersToColumnIndex := make(map[int]string)
for i, v := range header {
v := strings.TrimSpace(v)
switch strings.ToLower(v) {
case "employee", "hours worked", "hourly rate":
csvHeadersToColumnIndex[i] = v
}
}
fmt.Println(csvHeadersToColumnIndex)
}