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 pointer to struct in Go

1 Answer

0 votes
package main

import "fmt"

type Worker struct {
    id, age int
    name string
}
 

func main() {
	w := Worker{1345, 49, "Bob"}

	p := &w
	fmt.Println(w)
	fmt.Println(p)
	
	p.age = 51
	fmt.Println(w)
}



/*
run:

{1345 49 Bob}
&{1345 49 Bob}
{1345 51 Bob}

*/

 



answered Mar 7, 2020 by avibootz

Related questions

1 answer 182 views
3 answers 243 views
1 answer 150 views
150 views asked Aug 24, 2020 by avibootz
1 answer 200 views
2 answers 204 views
204 views asked Aug 9, 2020 by avibootz
6 answers 499 views
499 views asked Feb 25, 2020 by avibootz
3 answers 209 views
209 views asked Aug 15, 2020 by avibootz
...