Created
September 20, 2017 12:41
-
-
Save vladimirvivien/5210dae05fce3068f02eda5b01ba073a to your computer and use it in GitHub Desktop.
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() { | |
reader := strings.NewReader("Clear is better than clever") | |
p := make([]byte, 4) | |
for { | |
n, err := reader.Read(p) | |
if err != nil{ | |
if err == io.EOF { | |
fmt.Println(string(p[:n])) //should handle any remainding bytes. | |
break | |
} | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
fmt.Println(string(p[:n])) | |
} | |
} |
+1 to reordering. Having nested conditionals that increase the cognitive complexity is not idiomatic go.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would you consider reordering to improve clarity?