Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Created January 26, 2023 07:43
Show Gist options
  • Select an option

  • Save arriqaaq/cd43b48e7bae572f2ad5d54d5e5c98cd to your computer and use it in GitHub Desktop.

Select an option

Save arriqaaq/cd43b48e7bae572f2ad5d54d5e5c98cd to your computer and use it in GitHub Desktop.
type Person struct {
Name string
Age int
}
func (p *Person) Greet() string {
return "Hello, my name is " + p.Name
}
func (p *Person) Copy() *Person {
return &Person{
Name: p.Name,
Age: p.Age,
}
}
originalPerson := &Person{Name: "John", Age: 30}
clonedPerson := originalPerson.Copy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment