Last active
August 29, 2015 14:05
-
-
Save jimtla/32dab1bb0ea0424710f8 to your computer and use it in GitHub Desktop.
Code Sample for Go Leaks blog post
This file contains hidden or 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 createAlternateSizes(photoPath string, img image.Image, block bool) error { | |
// Put a white background on all the resized images. | |
whiteImg := imageWithWhiteBg(img) | |
c := make(chan error, 0) | |
go resizeAndWrite(whiteImg, 640, photoPath + "_f", c) | |
go resizeAndWrite(whiteImg, 290, photoPath + "_s", c) | |
go resizeAndWrite(whiteImg, 200, photoPath + "_d", c) | |
if block { | |
// Wait for three things to come back on the channel. | |
for i := 0; i < 3; i++ { | |
err = <-c | |
if err != nil { | |
s.Printf("ERR: %v", err) | |
return err | |
} | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment