Got up to pointers

master
AndroidDrew 7 years ago
parent a4520ed07d
commit 74ae9c42b9

@ -1,2 +1,9 @@
# golang_course
##Setting you GOPATH
`go env` will display your current GO Environment variables
### Windows
set GOPATH=C:\Users\Gideon\go\src\golang_course

@ -0,0 +1,16 @@
package main
import (
"fmt"
"runtime"
)
var (
name string
course string
module float64
)
func main() {
fmt.Println("Hello from: ", runtime.GOOS)
}

@ -0,0 +1,20 @@
package main
import (
"fmt"
"os"
)
var my_name = "Drew"
var program_name = os.Args[0]
func main() {
fmt.Println("Starting up program:", program_name)
change_name(&my_name)
fmt.Println("Ok so you name is:", my_name)
}
func change_name(name *string) {
*name = "Your name is no longer useful"
}

@ -0,0 +1,20 @@
package main
import (
"fmt"
"reflect"
)
var (
// alternative method
// name, course, module = "Nigel", "Docker Deep Dive", 3.2
name string = "Drew"
course string = "Docker Deep Dive"
module float64 = 3.2
)
func main() {
fmt.Println("Name is", name, "and is of type", reflect.TypeOf(name))
fmt.Println("Module is", module, "and is of type", reflect.TypeOf(module))
}

@ -0,0 +1,18 @@
package main
import (
"fmt"
"reflect"
)
func main() {
a := 10.000000000
b := 3
fmt.Println("\nA is type", reflect.TypeOf(a), "and B is of type", reflect.TypeOf(b))
c := int(a) + b
fmt.Println("\nC has value:", c, "and is of type", reflect.TypeOf(c))
}

@ -0,0 +1,17 @@
package main
import (
"fmt"
"reflect"
)
func main() {
name := "Drew"
//GO won't let us use unused variables inside of functions
//course string = "Docker Deep Dive"
module := 3.2
fmt.Println("Name is", name, "and is of type", reflect.TypeOf(name))
fmt.Println("Module is", module, "and is of type", reflect.TypeOf(module))
}

@ -0,0 +1,16 @@
package main
import (
"fmt"
)
var (
name string
course string
module float64
)
func main() {
fmt.Println("Name is set to ", name)
fmt.Println("Module is set to ", module)
}
Loading…
Cancel
Save