35 lines
1,015 B
Go
35 lines
1,015 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)
|
|
|
|
fmt.Printf("\n\n")
|
|
|
|
// car1.reset() // also functions/methods cannot be used outside of package itself
|
|
|
|
car1.Reset2() // works
|
|
fmt.Println(car1)
|
|
|
|
}
|