Created
August 21, 2014 23:54
-
-
Save jimtla/6693f7614ecfcd5fa7e9 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) | |
numberOfResizes := 3 | |
c := make(chan error, numberOfResizes) | |
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 < numberOfResizes; 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