struct example 1
This commit is contained in:
parent
e627044e4c
commit
7f5e074730
2 changed files with 15 additions and 0 deletions
2
main.go
2
main.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"golesson/maps"
|
"golesson/maps"
|
||||||
"golesson/pointers"
|
"golesson/pointers"
|
||||||
"golesson/slices"
|
"golesson/slices"
|
||||||
|
"golesson/structs"
|
||||||
"golesson/variables"
|
"golesson/variables"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -52,4 +53,5 @@ func main() {
|
||||||
numbers:=[]int{1,2,3}
|
numbers:=[]int{1,2,3}
|
||||||
pointers.Demo2(numbers)
|
pointers.Demo2(numbers)
|
||||||
fmt.Println("Numbers in Main", numbers[0])
|
fmt.Println("Numbers in Main", numbers[0])
|
||||||
|
structs.Demo1()
|
||||||
}
|
}
|
||||||
|
|
13
structs/demo1.go
Normal file
13
structs/demo1.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package structs
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func Demo1() {
|
||||||
|
fmt.Println(product{"Computer", 5000, "XYZ"})
|
||||||
|
}
|
||||||
|
|
||||||
|
type product struct {
|
||||||
|
name string
|
||||||
|
unitPrice float64
|
||||||
|
brand string
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue