iterating array

This commit is contained in:
ccppi 2024-03-21 12:57:33 +01:00
parent 1b875c7c67
commit 4e77b2fbd1

49
main.go
View File

@ -1 +1,48 @@
hallo package main
import (
"encoding/csv"
"fmt"
"log"
"os"
)
type app_record struct{
Name string
Version string
com string
flag1 bool
flag2 bool
}
func main(){
f, err := os.Open("data.csv")
if err != nil{
log.Fatal(err)
}
csvReader :=csv.NewReader(f)
data, err := csvReader.ReadAll()
if err != nil {
log.Fatal(err);
}
csv_to_array(data)
fmt.Printf("%v\n",data)
}
func csv_to_array(data[][]string) []app_record{
var app_list []app_record
for i, record := range data{
fmt.Printf("index: %v Entry: %v\n",i, record)
for j, item := range record{
fmt.Printf("indexj: %v, Entry:%v\n",j,item)
app_list[j].Name = item
}
//app_list[i].Name = record
}
return app_list
}