Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,851 questions

51,772 answers

573 users

How to use nested anonymous struct (struct inside struct) in Go

1 Answer

0 votes
package main
 
import "fmt"
 
type A struct {
	n int
	s string
	B struct {
		c int
		d int
	}
}
 
func main() {
	var st A 
	
	st.n = 23
	st.s = "go"
 
	st.B.c = 876
	st.B.d = 93
 
	fmt.Println(st)
	
	fmt.Println(st.n)
	fmt.Println(st.B.c)

}



/*
run:

{23 go {876 93}}
23
876

*/

 



answered Aug 23, 2020 by avibootz

Related questions

1 answer 149 views
149 views asked Aug 24, 2020 by avibootz
1 answer 174 views
2 answers 235 views
2 answers 231 views
231 views asked Sep 4, 2020 by avibootz
1 answer 181 views
2 answers 204 views
204 views asked Aug 9, 2020 by avibootz
1 answer 154 views
154 views asked Mar 7, 2020 by avibootz
...