SoFunction
Updated on 2025-03-05

Analyze the struct structure in Go programming


package main

import "fmt"

type A struct {
Name string //This is a common capitalization If it is a lowercase name, the package can be used privately.
}
type B struct {
 Name string
}

func main() {
 a := A{}
 b := B{}
 ()
 ()
}
//Get the name of the same method by different types
func (a *A) print() {
 ("A")
}

func (b *B) print() {
 ("B")
}