go-organization/simple-structure/package-str/example/main.go
2023-07-24 10:37:47 +03:00

27 lines
864 B
Go

package main
import (
"Liderahenk/go-organization/simple-structure/package-str/great"
"fmt"
)
func main() {
great.Hello()
fmt.Println(great.Name)
// fmt.Println(great.name2) // ERROR lowercase variables cannot be used outside of package itself
car1 := great.Car{Name: "bmw", Color: "red"}
// car1_1 := great.Car{"bmw", "red"} // TODO WHY THIS GIVES WARNING
fmt.Println(car1) // same with fmt.Println(car1.String()), bcs fmt uses String() by default
// car2 := great.car2{Name: "ford", Color: "green"} // ERROR lowercase structs cannot be used outside of package itself
fmt.Printf("\n\n")
// car3 := great.Car3{Name: "ford", color: "green"} // unknown field color, also lowercase struct variables cannot be used outside of package itself
car3_1 := great.Car3{}
car3_1.Name = "ford"
// car3_1.color = "green" // undefined
fmt.Println(car3_1)
}