Astaxie example to populate structure of arrays

Hi, I have a playground here
Need help regardingFriends: []*Friend{&res}}. How is it can be populated in this way? Thank you in advance.

My goal is to use Nested fields as in astaxie templates example.

As you still havent thought about your types, I give you this:

	res := []*Friend{}
	p := Person{UserName: "Astaxie",
		Emails:  []string{"", ""},
		Friends: res}

You need to fill in the holes on your own.

Really tried your hints, still in trouble. Golang is hard for me. Seems a simple task but not for me. Thanks for your time and help @NobbZ

But these are the things you need to understand.

If not you’ll hit this wall again and again.

I can only recommend to repeat the go tour over and over until you get the pointer, reference, slice stuff.

Ps: as I am using many languages, perhaps I can find some analogies when you tell me where you come from?

1 Like


I meant programming languages.

1 Like

))) I am a sysadmin, and I have not used any programming language before. Only Pascal (Delphi) which was 12 years ago.

Hmm… Okay, I have to dig a bit for that, let me see if I get the syntax right…

type Foo []int

Is roughly equivalent to

  Foo = Array of Integer;

type Foo struct {
  Bar int
  Foo = Record
    Bar : Integer

type Foo *int
  Foo = ^Integer;

I hope this helps you a bit to understand, but I have to be honest, I never liked Pascal that much and bypassed the pascal courses in university as they were just introductionary programming, and I was able to show some introductionary C certificates and opensource contributions which gave me equivalent creditpoints and I was able to skip those courses.

1 Like

great !