Update to gobook@c6d7a22edd03e7738c38d5baa2174ff325d8d863

This commit is contained in:
Alan Donovan
2015-10-28 14:20:59 -04:00
parent fce1727c4c
commit 30090035de
150 changed files with 8559 additions and 6 deletions
+42
View File
@@ -0,0 +1,42 @@
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// +build ignore
// The thumbnail command produces thumbnails of JPEG files
// whose names are provided on each line of the standard input.
//
// The "+build ignore" tag (see p.295) excludes this file from the
// thumbnail package, but it can be compiled as a command and run like
// this:
//
// Run with:
// $ go run $GOPATH/src/gopl.io/ch8/thumbnail/main.go
// foo.jpeg
// ^D
//
package main
import (
"bufio"
"fmt"
"log"
"os"
"gopl.io/ch8/thumbnail"
)
func main() {
input := bufio.NewScanner(os.Stdin)
for input.Scan() {
thumb, err := thumbnail.ImageFile(input.Text())
if err != nil {
log.Print(err)
continue
}
fmt.Println(thumb)
}
if err := input.Err(); err != nil {
log.Fatal(err)
}
}