package main import ( "encoding/gob" "log" "net" "os" ) type FileList struct { List []Item } type Item struct { Name string IsFolder bool } func main() { conn, err := net.Dial("tcp", "127.0.0.1:1337") if err != nil { log.Fatal(err) } defer conn.Close() newList := FileList{} list, _ := os.ReadDir("/home/raul") for _, v := range list { item := Item{ Name: v.Name(), IsFolder: v.IsDir(), } newList.List = append(newList.List, item) } enc := gob.NewEncoder(conn) err = enc.Encode(&newList) if err != nil { log.Fatalf("Error happened encoding: %v\n", err) } }