git.lucas.co / go_mono
git clone https://git.lucas.co/go_mono.git

commitc348254d65821a0aaca538bf5e7774bb522c1dec
parent81315f0c68
authorNigel Tao <[email protected]>
date2016-07-16 09:11
webp: make a placeholder package for Go 1.5 and earlier.

This lets programs that underscore import this package build on Go 1.5.

Change-Id: Icd977b16eb44389f8ee4640c2ab57e4b6791b1f4
Reviewed-on: https://go-review.googlesource.com/24954
Reviewed-by: Brad Fitzpatrick <[email protected]>

 webp/decode.go |  6 +-----
 webp/webp.go   | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/webp/decode.go b/webp/decode.go
index 488e0ab..111f358 100644
--- a/webp/decode.go
+++ b/webp/decode.go
@@ -4,11 +4,7 @@
 
 // +build go1.6
 
-// Package webp implements a decoder for WEBP images.
-//
-// WEBP is defined at:
-// https://developers.google.com/speed/webp/docs/riff_container
-package webp // import "golang.org/x/image/webp"
+package webp
 
 import (
 	"bytes"
diff --git a/webp/webp.go b/webp/webp.go
new file mode 100644
index 0000000..850cdc8
--- /dev/null
+++ b/webp/webp.go
@@ -0,0 +1,30 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package webp implements a decoder for WEBP images.
+//
+// WEBP is defined at:
+// https://developers.google.com/speed/webp/docs/riff_container
+//
+// It requires Go 1.6 or later.
+package webp // import "golang.org/x/image/webp"
+
+// This blank Go file, other than the package clause, exists so that this
+// package can be built for Go 1.5 and earlier. (The other files in this
+// package are all marked "+build go1.6" for the NYCbCrA types introduced in Go
+// 1.6). There is no functionality in a blank package, but some image
+// manipulation programs might still underscore import this package for the
+// side effect of registering the WEBP format with the standard library's
+// image.RegisterFormat and image.Decode functions. For example, that program
+// might contain:
+//
+//	// Underscore imports to register some formats for image.Decode.
+//	import _ "image/gif"
+//	import _ "image/jpeg"
+//	import _ "image/png"
+//	import _ "golang.org/x/image/webp"
+//
+// Such a program will still compile for Go 1.5 (due to this placeholder Go
+// file). It will simply not be able to recognize and decode WEBP (but still
+// handle GIF, JPEG and PNG).