Re: [go-nuts] List inside struct

2020-08-30 Thread Shyaka Rene
Thank you, it worked, everything is automatic in Go when you come from Rust and Java, Thank you again On Sun, Aug 30, 2020 at 2:59 AM Bakul Shah wrote: > Unless there is a very strong reason to use a doubly linked list, you > should just use a slice: > > type Persons struct { name string; Names

Re: [go-nuts] List inside struct

2020-08-29 Thread Bakul Shah
Unless there is a very strong reason to use a doubly linked list, you should just use a slice: type Persons struct { name string; Names []string } I redid your program using the above here: https://play.golang.org/p/x5I1wYiCNGA Sounds like you are coming from some object oriented language bac

Re: [go-nuts] List inside struct

2020-08-29 Thread Siddhesh Divekar
Shyaka, The list package does all operation on list pointer. In your case, I think you are passing list object instead of pointer. You have defined your structure as:- type Persons struct { name string Names list.List < Its a list object and not a pointer to list object. }

Re: [go-nuts] List inside struct

2020-08-29 Thread burak serdar
On Sat, Aug 29, 2020 at 2:01 PM Shyaka wrote: > > Hello, I need help, I have a struct Person wiith list inside, I add 5 string > on list at the end I found that the list is nil, I don't know whre is the > error, any help is appreciated. > > package main > > import ( > "container/list" >

Re: [go-nuts] List inside struct

2020-08-29 Thread Jan Mercl
On Sat, Aug 29, 2020 at 10:01 PM Shyaka wrote: > Hello, I need help, I have a struct Person wiith list inside, I add 5 string > on list at the end I found that the list is nil, I don't know whre is the > error, any help is appreciated. I don't know why you code doesn't work, but as a first thin

[go-nuts] List inside struct

2020-08-29 Thread Shyaka
Hello, I need help, I have a struct Person wiith list inside, I add 5 string on list at the end I found that the list is nil, I don't know whre is the error, any help is appreciated. package main import ( "container/list" "fmt" ) type Persons struct { name string Names list.Li