diff --git a/000_temp/63-fall-2018/010-hands-on/02/main.go b/000_temp/63-fall-2018/010-hands-on/02/main.go index 0e8d297b..06b30003 100644 --- a/000_temp/63-fall-2018/010-hands-on/02/main.go +++ b/000_temp/63-fall-2018/010-hands-on/02/main.go @@ -6,11 +6,10 @@ func main() { foo() } - // func receiver identifier(parameters) return(s) {code} func foo() { x := "James Bond" y := 32 fmt.Println(x, y) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/010-hands-on/03/main.go b/000_temp/63-fall-2018/010-hands-on/03/main.go index e15ff88c..2b50d353 100644 --- a/000_temp/63-fall-2018/010-hands-on/03/main.go +++ b/000_temp/63-fall-2018/010-hands-on/03/main.go @@ -11,7 +11,6 @@ func main() { foo("Cole", 19) } - // func // modularize our code and DRY (don't repeat yourself) // funcs are defined with parameters diff --git a/000_temp/63-fall-2018/010-hands-on/04/main.go b/000_temp/63-fall-2018/010-hands-on/04/main.go index 9d790777..63371834 100644 --- a/000_temp/63-fall-2018/010-hands-on/04/main.go +++ b/000_temp/63-fall-2018/010-hands-on/04/main.go @@ -7,8 +7,7 @@ func main() { fmt.Println(z) } - // func receiver identifier(parameters) returns {code} func foo(x int, y int) int { return x * y -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/010-hands-on/05/main.go b/000_temp/63-fall-2018/010-hands-on/05/main.go index 53cb74c7..8392d1fd 100644 --- a/000_temp/63-fall-2018/010-hands-on/05/main.go +++ b/000_temp/63-fall-2018/010-hands-on/05/main.go @@ -7,9 +7,8 @@ func main() { fmt.Println(x) } - // func receiver identifier(parameters) returns {code} func foo(s string) string { //return fmt.Sprint("Hello ", s, "!") return "Hello " + s + "!" -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/011-loops/main.go b/000_temp/63-fall-2018/011-loops/main.go index 330652c9..98f4b8dd 100644 --- a/000_temp/63-fall-2018/011-loops/main.go +++ b/000_temp/63-fall-2018/011-loops/main.go @@ -6,10 +6,9 @@ func main() { foo() } - // func receiver identifier(parameters) returns {code} func foo() { for i := 0; i <= 100; i++ { fmt.Println(i) } -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/012-conditional/main.go b/000_temp/63-fall-2018/012-conditional/main.go index c7f06600..13dd3037 100644 --- a/000_temp/63-fall-2018/012-conditional/main.go +++ b/000_temp/63-fall-2018/012-conditional/main.go @@ -6,12 +6,11 @@ func main() { foo() } - // func receiver identifier(parameters) returns {code} func foo() { for i := 0; i <= 100; i++ { - if i % 2 == 0 { + if i%2 == 0 { fmt.Println(i) } } -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/013-slice/main.go b/000_temp/63-fall-2018/013-slice/main.go index bc594823..a2a54bdc 100644 --- a/000_temp/63-fall-2018/013-slice/main.go +++ b/000_temp/63-fall-2018/013-slice/main.go @@ -3,7 +3,7 @@ package main import "fmt" func main() { - xi := []int{2,3,4,5,6,7,8} + xi := []int{2, 3, 4, 5, 6, 7, 8} fmt.Println(xi) for i, v := range xi { diff --git a/000_temp/63-fall-2018/014-maps/main.go b/000_temp/63-fall-2018/014-maps/main.go index 5d2ab53f..0732c53b 100644 --- a/000_temp/63-fall-2018/014-maps/main.go +++ b/000_temp/63-fall-2018/014-maps/main.go @@ -3,7 +3,7 @@ package main import "fmt" func main() { - m := map[string]int{"James":32, "Jenny":27,} + m := map[string]int{"James": 32, "Jenny": 27} fmt.Println(m) for k, v := range m { diff --git a/000_temp/63-fall-2018/015-struct/main.go b/000_temp/63-fall-2018/015-struct/main.go index 8fcf44d6..1fe72944 100644 --- a/000_temp/63-fall-2018/015-struct/main.go +++ b/000_temp/63-fall-2018/015-struct/main.go @@ -3,26 +3,26 @@ package main import "fmt" type person struct { - first string - last string - age int + first string + last string + age int sayings []string } func main() { p1 := person{ - first: "James", - last: "Bond", - age: 32, - sayings: []string{"Shaken, not stirred", "Bond, James Bond",}, + first: "James", + last: "Bond", + age: 32, + sayings: []string{"Shaken, not stirred", "Bond, James Bond"}, } fmt.Println(p1) p2 := person{ - first: "Jenny", - last: "Moneypenny", - age: 27, - sayings: []string{"Danger knows no gender", "A woman's place is in control",}, + first: "Jenny", + last: "Moneypenny", + age: 27, + sayings: []string{"Danger knows no gender", "A woman's place is in control"}, } fmt.Println(p2) @@ -37,7 +37,7 @@ func main() { } fmt.Println("---------") - m := map[string]person{"James":p1, "Jenny":p2,} + m := map[string]person{"James": p1, "Jenny": p2} for k, p := range m { fmt.Println(k, p) diff --git a/000_temp/63-fall-2018/016-fun-with-text/main.go b/000_temp/63-fall-2018/016-fun-with-text/main.go index bc445452..da0c8289 100644 --- a/000_temp/63-fall-2018/016-fun-with-text/main.go +++ b/000_temp/63-fall-2018/016-fun-with-text/main.go @@ -15,4 +15,4 @@ func main() { fmt.Printf("%d - %b - %#X\n", v, v, v) } -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/017-slice/main.go b/000_temp/63-fall-2018/017-slice/main.go index ea59942c..c4775c31 100644 --- a/000_temp/63-fall-2018/017-slice/main.go +++ b/000_temp/63-fall-2018/017-slice/main.go @@ -22,4 +22,4 @@ func main() { fmt.Printf("%T\n", xs) fmt.Println(xs) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/018-map/main.go b/000_temp/63-fall-2018/018-map/main.go index c84807fd..bbcd2fb6 100644 --- a/000_temp/63-fall-2018/018-map/main.go +++ b/000_temp/63-fall-2018/018-map/main.go @@ -3,9 +3,9 @@ package main import "fmt" func main() { - m := map[string]int{"James":7, "Jenny":8,} + m := map[string]int{"James": 7, "Jenny": 8} fmt.Printf("%T\n", m) fmt.Println(m) fmt.Println(m["James"]) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/019-struct/01/main.go b/000_temp/63-fall-2018/019-struct/01/main.go index d32ae55d..da9a6f35 100644 --- a/000_temp/63-fall-2018/019-struct/01/main.go +++ b/000_temp/63-fall-2018/019-struct/01/main.go @@ -3,6 +3,7 @@ package _1 import "fmt" type hotdog int + var x hotdog func main() { @@ -13,4 +14,4 @@ func main() { fmt.Printf("%T\n", y) fmt.Println(y) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/019-struct/02/main.go b/000_temp/63-fall-2018/019-struct/02/main.go index 7cb3b388..005acb9d 100644 --- a/000_temp/63-fall-2018/019-struct/02/main.go +++ b/000_temp/63-fall-2018/019-struct/02/main.go @@ -3,16 +3,16 @@ package main import "fmt" type person struct { - first string + first string license int sayings []string } func main() { p1 := person{ - first: "James", + first: "James", license: 007, - sayings: []string{"Shaken, not stirred", "Bond, James Bond",}, + sayings: []string{"Shaken, not stirred", "Bond, James Bond"}, } fmt.Println(p1) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/019-struct/03/main.go b/000_temp/63-fall-2018/019-struct/03/main.go index 61de635f..0a11ccb8 100644 --- a/000_temp/63-fall-2018/019-struct/03/main.go +++ b/000_temp/63-fall-2018/019-struct/03/main.go @@ -3,29 +3,29 @@ package main import "fmt" type person struct { - first string + first string license int sayings []string } func main() { p1 := person{ - first: "James", + first: "James", license: 7, - sayings: []string{"Shaken, not stirred", "Bond, James Bond",}, + sayings: []string{"Shaken, not stirred", "Bond, James Bond"}, } fmt.Println(p1) p2 := person{ - first: "Jenny", + first: "Jenny", license: 8, - sayings: []string{"When Bond can't handle it, call me", "I will always love Bond",}, + sayings: []string{"When Bond can't handle it, call me", "I will always love Bond"}, } fmt.Println(p2) xp := []person{p1, p2} fmt.Println(xp) - mp := map[string]person{"Mr":p1, "Ms":p2,} + mp := map[string]person{"Mr": p1, "Ms": p2} fmt.Println(mp) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/020-looping/02/main.go b/000_temp/63-fall-2018/020-looping/02/main.go index 1fb0b8ee..35e9ef03 100644 --- a/000_temp/63-fall-2018/020-looping/02/main.go +++ b/000_temp/63-fall-2018/020-looping/02/main.go @@ -14,10 +14,10 @@ func main() { } for _, val := range xi { - fmt.Println("-",val) + fmt.Println("-", val) } - m := map[string]int{"James":32, "Jenny":27,} + m := map[string]int{"James": 32, "Jenny": 27} for k, v := range m { fmt.Println(k, v) @@ -30,4 +30,4 @@ func main() { for _, value := range m { fmt.Println("-", value) } -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/021-receiver/01/main.go b/000_temp/63-fall-2018/021-receiver/01/main.go index 608fdde7..be330a10 100644 --- a/000_temp/63-fall-2018/021-receiver/01/main.go +++ b/000_temp/63-fall-2018/021-receiver/01/main.go @@ -3,8 +3,8 @@ package main import "fmt" type person struct { - first string - last string + first string + last string saying string } @@ -16,14 +16,14 @@ func (p person) speak() { func main() { p1 := person{ - first: "James", - last: "Bond", + first: "James", + last: "Bond", saying: "Shaken, not stirred.", } p2 := person{ - first: "Jenny", - last: "Moneypenny", + first: "Jenny", + last: "Moneypenny", saying: "Helllllllo, James.", } diff --git a/000_temp/63-fall-2018/022-interfaces/01/main.go b/000_temp/63-fall-2018/022-interfaces/01/main.go index e194fb3a..301c5996 100644 --- a/000_temp/63-fall-2018/022-interfaces/01/main.go +++ b/000_temp/63-fall-2018/022-interfaces/01/main.go @@ -3,8 +3,8 @@ package main import "fmt" type person struct { - first string - last string + first string + last string saying string } @@ -30,21 +30,21 @@ func foo(h human) { func main() { p1 := person{ - first: "James", - last: "Bond", + first: "James", + last: "Bond", saying: "Shaken, not stirred.", } p2 := person{ - first: "Jenny", - last: "Moneypenny", + first: "Jenny", + last: "Moneypenny", saying: "Helllllllo, James.", } sa1 := secretAgent{ person: person{ - first: "Ian", - last: "Fleming", + first: "Ian", + last: "Fleming", saying: "The books were based on real stories", }, ltk: true, diff --git a/000_temp/63-fall-2018/022-interfaces/02/main.go b/000_temp/63-fall-2018/022-interfaces/02/main.go index e194fb3a..301c5996 100644 --- a/000_temp/63-fall-2018/022-interfaces/02/main.go +++ b/000_temp/63-fall-2018/022-interfaces/02/main.go @@ -3,8 +3,8 @@ package main import "fmt" type person struct { - first string - last string + first string + last string saying string } @@ -30,21 +30,21 @@ func foo(h human) { func main() { p1 := person{ - first: "James", - last: "Bond", + first: "James", + last: "Bond", saying: "Shaken, not stirred.", } p2 := person{ - first: "Jenny", - last: "Moneypenny", + first: "Jenny", + last: "Moneypenny", saying: "Helllllllo, James.", } sa1 := secretAgent{ person: person{ - first: "Ian", - last: "Fleming", + first: "Ian", + last: "Fleming", saying: "The books were based on real stories", }, ltk: true, diff --git a/000_temp/63-fall-2018/023-review/main.go b/000_temp/63-fall-2018/023-review/main.go index 9f33dc01..663f1e30 100644 --- a/000_temp/63-fall-2018/023-review/main.go +++ b/000_temp/63-fall-2018/023-review/main.go @@ -8,8 +8,8 @@ var d = 43 const z = 142 type person struct { - first string - age int + first string + age int saying string } @@ -53,7 +53,7 @@ func main() { // slice AGGREGATE or COMPOSITE data structure - ee := []int{2,3,4,7,9,} + ee := []int{2, 3, 4, 7, 9} fmt.Println(ee) // it was going SEQUENCE @@ -67,9 +67,8 @@ func main() { } } - // map AGGREGATE or COMPOSITE data structure - f := map[string]int{"James":32, "Jenny":27,} + f := map[string]int{"James": 32, "Jenny": 27} fmt.Println(f) for k, v := range f { @@ -78,14 +77,14 @@ func main() { // struct AGGREGATE or COMPOSITE data structure p1 := person{ - first: "James", - age: 32, + first: "James", + age: 32, saying: "shaken, not stirred", } - p2 := person { - first: "Jenny", - age: 27, + p2 := person{ + first: "Jenny", + age: 27, saying: "nobody does it better", } @@ -102,8 +101,8 @@ func main() { sa1 := secretagent{ person: person{ - first: "Jack", - age: 29, + first: "Jack", + age: 29, saying: "Blahb blahblabhalbhablhab", }, ltk: true, diff --git a/000_temp/63-fall-2018/024-unfurling-slice/main.go b/000_temp/63-fall-2018/024-unfurling-slice/main.go index 5cbce4f9..2870a3af 100644 --- a/000_temp/63-fall-2018/024-unfurling-slice/main.go +++ b/000_temp/63-fall-2018/024-unfurling-slice/main.go @@ -3,11 +3,11 @@ package main import "fmt" func main() { - xi := []int{1,2,4,5,7,8,9,} + xi := []int{1, 2, 4, 5, 7, 8, 9} foo(xi...) } func foo(i ...int) { fmt.Println(i) fmt.Printf("%T\n", i) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/025-defer/main.go b/000_temp/63-fall-2018/025-defer/main.go index 26cd71ca..08d33d20 100644 --- a/000_temp/63-fall-2018/025-defer/main.go +++ b/000_temp/63-fall-2018/025-defer/main.go @@ -23,4 +23,4 @@ func one() { func two() { fmt.Println("twoooooooooo") -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/026-anonymous-func/main.go b/000_temp/63-fall-2018/026-anonymous-func/main.go index 6f1cd19d..9271c3d6 100644 --- a/000_temp/63-fall-2018/026-anonymous-func/main.go +++ b/000_temp/63-fall-2018/026-anonymous-func/main.go @@ -7,9 +7,9 @@ func main() { // anonymous func - func(x int){ + func(x int) { fmt.Println(x) }(4) } -func foo() {fmt.Println("this is foo")} \ No newline at end of file +func foo() { fmt.Println("this is foo") } diff --git a/000_temp/63-fall-2018/027-func-expression/main.go b/000_temp/63-fall-2018/027-func-expression/main.go index f536aab4..7c9531f9 100644 --- a/000_temp/63-fall-2018/027-func-expression/main.go +++ b/000_temp/63-fall-2018/027-func-expression/main.go @@ -7,7 +7,7 @@ func main() { fmt.Println(a) d := 14 - b := func(z string){ + b := func(z string) { fmt.Println(z) } @@ -18,10 +18,10 @@ func main() { b("jenny") x := foo("cat") y := foo("bird") - fmt.Println(x,y) + fmt.Println(x, y) fmt.Println(d) } func foo(s string) string { return s + "dogggggggg" -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/028-returning-a-func/main.go b/000_temp/63-fall-2018/028-returning-a-func/main.go index 9fc52167..a0e34398 100644 --- a/000_temp/63-fall-2018/028-returning-a-func/main.go +++ b/000_temp/63-fall-2018/028-returning-a-func/main.go @@ -5,9 +5,9 @@ import "fmt" func main() { x := foo() y := foo() - fmt.Printf("%T\t %T\n", x,y) + fmt.Printf("%T\t %T\n", x, y) - func(z string){ + func(z string) { fmt.Println(z) }("james") @@ -17,7 +17,7 @@ func main() { } func foo() func(string) { - return func(z string){ + return func(z string) { fmt.Println(z) } -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/029-pointers/main.go b/000_temp/63-fall-2018/029-pointers/main.go index e53221a7..2420c2f6 100644 --- a/000_temp/63-fall-2018/029-pointers/main.go +++ b/000_temp/63-fall-2018/029-pointers/main.go @@ -16,4 +16,4 @@ func main() { *y = 43 fmt.Println(x) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/030-os-args/main.go b/000_temp/63-fall-2018/030-os-args/main.go index 2babcccd..5868877c 100644 --- a/000_temp/63-fall-2018/030-os-args/main.go +++ b/000_temp/63-fall-2018/030-os-args/main.go @@ -1,8 +1,8 @@ package main import ( - "os" "fmt" + "os" ) func main() { diff --git a/000_temp/63-fall-2018/031-string-template/main.go b/000_temp/63-fall-2018/031-string-template/main.go index 7d1d6803..fa04dcd4 100644 --- a/000_temp/63-fall-2018/031-string-template/main.go +++ b/000_temp/63-fall-2018/031-string-template/main.go @@ -2,10 +2,10 @@ package main import ( "fmt" - "os" + "io" "log" + "os" "strings" - "io" ) func main() { diff --git a/000_temp/63-fall-2018/032-text-template/main.go b/000_temp/63-fall-2018/032-text-template/main.go index 6285de4a..81e7733b 100644 --- a/000_temp/63-fall-2018/032-text-template/main.go +++ b/000_temp/63-fall-2018/032-text-template/main.go @@ -1,10 +1,10 @@ package main import ( - "text/template" + "fmt" "log" "os" - "fmt" + "text/template" ) func main() { diff --git a/000_temp/63-fall-2018/033-parseglob/main.go b/000_temp/63-fall-2018/033-parseglob/main.go index 0d024b14..660e28ab 100644 --- a/000_temp/63-fall-2018/033-parseglob/main.go +++ b/000_temp/63-fall-2018/033-parseglob/main.go @@ -1,8 +1,8 @@ package main import ( - "text/template" "os" + "text/template" ) var tpl *template.Template diff --git a/000_temp/63-fall-2018/034-pass-in-data-aggregate/main.go b/000_temp/63-fall-2018/034-pass-in-data-aggregate/main.go index 4138fcfa..5fae3d01 100644 --- a/000_temp/63-fall-2018/034-pass-in-data-aggregate/main.go +++ b/000_temp/63-fall-2018/034-pass-in-data-aggregate/main.go @@ -1,8 +1,8 @@ package main import ( - "text/template" "os" + "text/template" ) var tpl *template.Template @@ -13,16 +13,16 @@ func init() { type person struct { First string - Last string - Age int + Last string + Age int } func main() { p1 := person{ First: "James", - Last: "Bond", - Age: 32, + Last: "Bond", + Age: 32, } err := tpl.ExecuteTemplate(os.Stdout, "one.gohtml", p1) @@ -32,8 +32,8 @@ func main() { p2 := person{ First: "Jenny", - Last: "Moneypenny", - Age: 27, + Last: "Moneypenny", + Age: 27, } xp := []person{p1, p2} diff --git a/000_temp/63-fall-2018/035-hash-bucket/main.go b/000_temp/63-fall-2018/035-hash-bucket/main.go index abc30424..fd2d43b7 100644 --- a/000_temp/63-fall-2018/035-hash-bucket/main.go +++ b/000_temp/63-fall-2018/035-hash-bucket/main.go @@ -38,4 +38,4 @@ func hashBucket(word string) int { fmt.Print(word[0], " ---- ") fmt.Printf("%#U\n", word[0]) return int(word[0]) -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/036-templates-review/main.go b/000_temp/63-fall-2018/036-templates-review/main.go index ebbb00ac..806ab44b 100644 --- a/000_temp/63-fall-2018/036-templates-review/main.go +++ b/000_temp/63-fall-2018/036-templates-review/main.go @@ -2,8 +2,8 @@ package main import ( "html/template" - "os" "log" + "os" ) var tpl *template.Template @@ -45,5 +45,4 @@ func main() { log.Fatal("there was an error", err) } - -} \ No newline at end of file +} diff --git a/000_temp/63-fall-2018/037-data/01/main.go b/000_temp/63-fall-2018/037-data/01/main.go index fd858f6f..340d7bdc 100644 --- a/000_temp/63-fall-2018/037-data/01/main.go +++ b/000_temp/63-fall-2018/037-data/01/main.go @@ -2,8 +2,8 @@ package main import ( "html/template" - "os" "log" + "os" ) var tpl *template.Template @@ -30,8 +30,7 @@ func main() { panic(err) } - - xi := []int{7,8,9,125,345,} + xi := []int{7, 8, 9, 125, 345} err = tpl.ExecuteTemplate(f2, "about.gohtml", xi) if err != nil { panic(err) diff --git a/000_temp/63-fall-2018/037-data/02/main.go b/000_temp/63-fall-2018/037-data/02/main.go index 957a710c..7ca6dcd4 100644 --- a/000_temp/63-fall-2018/037-data/02/main.go +++ b/000_temp/63-fall-2018/037-data/02/main.go @@ -2,8 +2,8 @@ package main import ( "html/template" - "os" "log" + "os" ) var tpl *template.Template @@ -31,7 +31,6 @@ func main() { panic(err) } - t := ` here is a raw string diff --git a/000_temp/63-fall-2018/037-data/03/main.go b/000_temp/63-fall-2018/037-data/03/main.go index ca00444a..df79fde9 100644 --- a/000_temp/63-fall-2018/037-data/03/main.go +++ b/000_temp/63-fall-2018/037-data/03/main.go @@ -2,8 +2,8 @@ package main import ( "html/template" - "os" "log" + "os" ) var tpl *template.Template @@ -31,7 +31,6 @@ func main() { panic(err) } - f := false err = tpl.ExecuteTemplate(f2, "about.gohtml", f) if err != nil { diff --git a/000_temp/64-HANDLER/main.go b/000_temp/64-HANDLER/main.go index b5b6687c..aec134db 100644 --- a/000_temp/64-HANDLER/main.go +++ b/000_temp/64-HANDLER/main.go @@ -1,11 +1,10 @@ package main import ( - "net/http" "io" + "net/http" ) - type hotdog int // func receiver identifier(params) return(s) {} @@ -25,4 +24,4 @@ type Handler interface { ServeHTTP(ResponseWriter, *Request) } -*/ \ No newline at end of file +*/ diff --git a/000_temp/65-DEFAULT-SERVE-MUX/main.go b/000_temp/65-DEFAULT-SERVE-MUX/main.go index cce7dabe..23a13c24 100644 --- a/000_temp/65-DEFAULT-SERVE-MUX/main.go +++ b/000_temp/65-DEFAULT-SERVE-MUX/main.go @@ -1,14 +1,13 @@ package main import ( - "net/http" - "log" "fmt" "html" "io" + "log" + "net/http" ) - type hotdog int func (h hotdog) ServeHTTP(w http.ResponseWriter, r *http.Request) { @@ -27,7 +26,6 @@ func main() { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) }) - log.Fatal(http.ListenAndServe(":8080", nil)) } @@ -36,7 +34,6 @@ func fooHandler(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "hello from foo") } - /* type Handler @@ -44,4 +41,4 @@ type Handler interface { ServeHTTP(ResponseWriter, *Request) } -*/ \ No newline at end of file +*/ diff --git a/000_temp/66-HANDLEFUNC/main.go b/000_temp/66-HANDLEFUNC/main.go index 6eb300f5..89a3e730 100644 --- a/000_temp/66-HANDLEFUNC/main.go +++ b/000_temp/66-HANDLEFUNC/main.go @@ -1,9 +1,9 @@ package main import ( - "net/http" - "io" "fmt" + "io" + "net/http" ) func main() { @@ -18,10 +18,10 @@ func home(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "hello from home") } -func about (w http.ResponseWriter, r *http.Request) { +func about(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "wassup from about") } -func contact (w http.ResponseWriter, r * http.Request) { +func contact(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "get in touch with us, yo, here at contact") } diff --git a/000_temp/67-KABOOM-BOOOYAH/main.go b/000_temp/67-KABOOM-BOOOYAH/main.go index efbb3464..10cde19e 100644 --- a/000_temp/67-KABOOM-BOOOYAH/main.go +++ b/000_temp/67-KABOOM-BOOOYAH/main.go @@ -1,8 +1,8 @@ package main import ( - "net/http" "html/template" + "net/http" ) var tpl *template.Template @@ -23,10 +23,10 @@ func home(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "default.gohtml", nil) } -func about (w http.ResponseWriter, r *http.Request) { +func about(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "about.gohtml", nil) } -func contact (w http.ResponseWriter, r * http.Request) { +func contact(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "contact.gohtml", nil) } diff --git a/000_temp/69-review-golang/main.go b/000_temp/69-review-golang/main.go index 79853a7c..4eab484b 100644 --- a/000_temp/69-review-golang/main.go +++ b/000_temp/69-review-golang/main.go @@ -25,4 +25,4 @@ func def(w http.ResponseWriter, r *http.Request) { func abo(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "about.gohtml", nil) -} \ No newline at end of file +} diff --git a/000_temp/71/main.go b/000_temp/71/main.go index dc7e34b2..eb3782b3 100644 --- a/000_temp/71/main.go +++ b/000_temp/71/main.go @@ -24,4 +24,4 @@ func hom(w http.ResponseWriter, r *http.Request) { func abo(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "about.gohtml", nil) -} \ No newline at end of file +} diff --git a/000_temp/73/01/main.go b/000_temp/73/01/main.go index 8fd45780..95fa031a 100644 --- a/000_temp/73/01/main.go +++ b/000_temp/73/01/main.go @@ -2,7 +2,6 @@ package main import "fmt" - // a VALUE of TYPE var x int @@ -24,4 +23,4 @@ func main() { fmt.Println(f, g, h, j) fmt.Printf("%T\t %T\t %T\t %T\t \n", f, g, h, j) -} \ No newline at end of file +} diff --git a/000_temp/73/02/main.go b/000_temp/73/02/main.go index f6b872e7..0388f4d6 100644 --- a/000_temp/73/02/main.go +++ b/000_temp/73/02/main.go @@ -4,7 +4,7 @@ import "fmt" // AGGREGATE or COMPOSITE func main() { - xi := []int{4,5,6,7,42} + xi := []int{4, 5, 6, 7, 42} fmt.Println(xi) diff --git a/000_temp/73/04/main.go b/000_temp/73/04/main.go index 6b2ef70d..474d752c 100644 --- a/000_temp/73/04/main.go +++ b/000_temp/73/04/main.go @@ -4,7 +4,7 @@ import "fmt" type person struct { first string - age int + age int } type secretAgent struct { @@ -15,17 +15,17 @@ type secretAgent struct { func main() { p := person{ first: "Miss Moneypenny", - age: 27, + age: 27, } - sa := secretAgent { - person: person { + sa := secretAgent{ + person: person{ first: "James", - age: 32, + age: 32, }, ltk: true, } fmt.Println(p) fmt.Println(sa) -} \ No newline at end of file +} diff --git a/000_temp/73/06/main.go b/000_temp/73/06/main.go index fb9b32f5..2db4ce4d 100644 --- a/000_temp/73/06/main.go +++ b/000_temp/73/06/main.go @@ -13,7 +13,6 @@ func main() { fmt.Println("a after bar", a) } - func foo(b int) { b = 43 fmt.Println("b", b) @@ -23,4 +22,4 @@ func bar(c *int) { *c = 44 fmt.Println("c", c) fmt.Println("*c", *c) -} \ No newline at end of file +} diff --git a/000_temp/75/main.go b/000_temp/75/main.go index d2803717..8a7a4074 100644 --- a/000_temp/75/main.go +++ b/000_temp/75/main.go @@ -65,12 +65,10 @@ func con2(w http.ResponseWriter, r *http.Request) { tpl2.ExecuteTemplate(w, "contact.gohtml", nil) } - func con3(w http.ResponseWriter, r *http.Request) { tpl3.ExecuteTemplate(w, "contact.gohtml", nil) } - func con4(w http.ResponseWriter, r *http.Request) { tpl4.ExecuteTemplate(w, "pale", nil) } diff --git a/000_temp/77-web-server/main.go b/000_temp/77-web-server/main.go index be55885b..66e55de7 100644 --- a/000_temp/77-web-server/main.go +++ b/000_temp/77-web-server/main.go @@ -6,13 +6,14 @@ import ( ) var tpl *template.Template + func init() { tpl = template.Must(template.ParseGlob("templates/*.gohtml")) } func main() { http.HandleFunc("/", foo) - http.HandleFunc("/about", bar ) + http.HandleFunc("/about", bar) http.HandleFunc("/contact", con) http.Handle("/resources/", http.StripPrefix("/resources", http.FileServer(http.Dir("./assets")))) http.ListenAndServe(":8080", nil) @@ -23,28 +24,27 @@ func foo(w http.ResponseWriter, r *http.Request) { } func bar(w http.ResponseWriter, r *http.Request) { - tpl.ExecuteTemplate(w, "about.gohtml", []int{1,2,3,4,5,6,7,8,9}) + tpl.ExecuteTemplate(w, "about.gohtml", []int{1, 2, 3, 4, 5, 6, 7, 8, 9}) } func con(w http.ResponseWriter, r *http.Request) { type person struct { First string - Age int + Age int } p1 := person{ First: "James", - Age: 32, + Age: 32, } - p2 := person { + p2 := person{ First: "Jenny", - Age: 27, + Age: 27, } xp := []person{p1, p2} - tpl.ExecuteTemplate(w, "contact.gohtml", xp) } diff --git a/000_temp/78/main.go b/000_temp/78/main.go index 70a2a72d..49ec19ea 100644 --- a/000_temp/78/main.go +++ b/000_temp/78/main.go @@ -1,11 +1,11 @@ package main import ( - "net/http" "fmt" "html/template" - "os" "io" + "net/http" + "os" ) var tpl *template.Template @@ -14,7 +14,6 @@ func init() { tpl = template.Must(template.ParseGlob("templates/*.gohtml")) } - func main() { http.HandleFunc("/", foo) http.Handle("/resources/", http.StripPrefix("/resources", http.FileServer(http.Dir("./assets")))) @@ -37,7 +36,7 @@ func foo(w http.ResponseWriter, r *http.Request) { fn = h.Filename - df, err := os.Create("./assets/"+fn) + df, err := os.Create("./assets/" + fn) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -53,5 +52,5 @@ func foo(w http.ResponseWriter, r *http.Request) { // w.Header().Set("Content-Type", "text/html; charset=utf-8") - tpl.ExecuteTemplate(w, "index.gohtml", fn) + tpl.ExecuteTemplate(w, "index.gohtml", fn) } diff --git a/000_temp/80-renamer/main.go b/000_temp/80-renamer/main.go index 513f5ff5..94cbf541 100644 --- a/000_temp/80-renamer/main.go +++ b/000_temp/80-renamer/main.go @@ -24,4 +24,4 @@ func main() { return } } -} \ No newline at end of file +} diff --git a/000_temp/81-cookie-counter/main.go b/000_temp/81-cookie-counter/main.go index e223f3cf..b56fd7eb 100644 --- a/000_temp/81-cookie-counter/main.go +++ b/000_temp/81-cookie-counter/main.go @@ -1,10 +1,10 @@ package main import ( - "net/http" + "fmt" "html/template" + "net/http" "strconv" - "fmt" ) var tpl *template.Template @@ -30,7 +30,6 @@ func foo(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "index.gohtml", c.Value) } - func bar(w http.ResponseWriter, r *http.Request) { c, err := cookieCounter(r) if err != nil { @@ -49,9 +48,9 @@ func cookieCounter(r *http.Request) (*http.Cookie, error) { c, err := r.Cookie("wackadoodle") if err != nil { c = &http.Cookie{ - Name: "wackadoodle", + Name: "wackadoodle", Value: "0", - Path: "/", + Path: "/", } } diff --git a/000_temp/82/main.go b/000_temp/82/main.go index 180f8828..0f767517 100644 --- a/000_temp/82/main.go +++ b/000_temp/82/main.go @@ -6,5 +6,5 @@ func main() { var x uint x = 18446744073709551615 fmt.Println(x) - fmt.Printf("%T\n\n",x) + fmt.Printf("%T\n\n", x) } diff --git a/000_temp/84-pg-query/main.go b/000_temp/84-pg-query/main.go index ca56408b..b0a5efc5 100644 --- a/000_temp/84-pg-query/main.go +++ b/000_temp/84-pg-query/main.go @@ -7,10 +7,10 @@ import ( ) type Book struct { - ISBN string - Title string + ISBN string + Title string Author string - Price float32 + Price float32 } func main() { @@ -38,11 +38,11 @@ func main() { xb = append(xb, b) if err = rs.Err(); err != nil { - panic(err) + panic(err) } } for i, v := range xb { fmt.Println(i, v) } -} \ No newline at end of file +} diff --git a/000_temp/85-pg-query-web/main.go b/000_temp/85-pg-query-web/main.go index 4711d308..2d549dd4 100644 --- a/000_temp/85-pg-query-web/main.go +++ b/000_temp/85-pg-query-web/main.go @@ -31,10 +31,10 @@ func init() { } type Book struct { - Isbn string - Title string + Isbn string + Title string Author string - Price float32 + Price float32 } func main() { @@ -58,8 +58,6 @@ func foo(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "books.gohtml", xb) } - - //rs, err := db.Query("select * from books;") //if err != nil { // http.Error(w, http.StatusText(500), 500) diff --git a/000_temp/88-whole-enchilada/main.go b/000_temp/88-whole-enchilada/main.go index 6c587e24..59c69841 100644 --- a/000_temp/88-whole-enchilada/main.go +++ b/000_temp/88-whole-enchilada/main.go @@ -1,16 +1,16 @@ package main import ( - "html/template" - "net/http" - _ "github.com/lib/pq" "database/sql" - "log" "fmt" + _ "github.com/lib/pq" + "html/template" + "log" + "net/http" ) type customer struct { - ID int + ID int First string } diff --git a/000_temp/92-whole-enchilada-2/main.go b/000_temp/92-whole-enchilada-2/main.go index 9bdcdea6..5f914568 100644 --- a/000_temp/92-whole-enchilada-2/main.go +++ b/000_temp/92-whole-enchilada-2/main.go @@ -1,16 +1,16 @@ package main import ( - "html/template" - "net/http" - _ "github.com/lib/pq" "database/sql" - "log" "fmt" + _ "github.com/lib/pq" + "html/template" + "log" + "net/http" ) type customer struct { - ID int + ID int First string } @@ -93,7 +93,6 @@ func create(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/", http.StatusFound) } - // UPDATE func up(w http.ResponseWriter, r *http.Request) { @@ -118,7 +117,6 @@ func up(w http.ResponseWriter, r *http.Request) { tpl.ExecuteTemplate(w, "update.gohtml", c) } - func ptoo(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Redirect(w, r, "/", http.StatusFound) @@ -146,7 +144,6 @@ func ptoo(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/", http.StatusFound) } - // DELETE func del(w http.ResponseWriter, r *http.Request) { @@ -157,7 +154,6 @@ func del(w http.ResponseWriter, r *http.Request) { customerid := r.FormValue("recordid") - result, err := db.Exec("DELETE FROM customers WHERE cid = $1;", customerid) if err != nil { http.Error(w, "didn't delete", http.StatusInternalServerError) diff --git a/003_string-to-html/01_stdout/main.go b/003_string-to-html/01_stdout/main.go index 4c834a5f..e422be0b 100644 --- a/003_string-to-html/01_stdout/main.go +++ b/003_string-to-html/01_stdout/main.go @@ -4,6 +4,7 @@ import "fmt" func main() { name := "Todd McLeod" + age := "36" tpl := ` @@ -14,6 +15,7 @@ func main() {