This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
s := foo() | |
fmt.Printf("main received: %q\n", s) | |
} | |
func foo() (s string) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
s := foo() | |
fmt.Printf("main received: %q\n", s) | |
} | |
func foo() string { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "fmt" | |
func main() { | |
freakOut() | |
fmt.Println("Exiting normally") | |
} | |
func freakOut() { | |
defer calmDown() | |
panic("Oh no") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
One() | |
} | |
func One() { | |
Two() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main() { | |
One() | |
} | |
func One() { | |
Two() | |
} | |
func Two() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GetFloats(fileName string)([]float64, error){ | |
var numbers []float64 | |
file, err := OpenFile(fileName) | |
if err != nil { | |
return nil, err | |
} | |
defer CloseFile(file) | |
scanner := bufio.NewScanner(file) | |
for scanner.Scan(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
numbers, err := GetFloats("numbers.txt") | |
if err != nil { | |
log.Fatal(err) | |
} | |
var sum float64 = 0 | |
for _, number := range numbers { | |
sum += number | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
"strconv" | |
) |