From cc41fcfd8c112c3145022a30e55ec6d8a8fc7c4c Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 8 May 2020 09:55:00 -0400 Subject: [PATCH] [x/tour] pic: document package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Effective Go¹ says every package should have a package comment, and every exported name in a package should have a doc comment. This package is mentioned in the Go tour. Let's set a good example. ¹ https://golang.org/doc/effective_go.html#commentary Change-Id: Iac561c7530fc49d5ff17c51d925151ec8319ef24 Reviewed-on: https://go-review.googlesource.com/c/tour/+/232865 Run-TryBot: Dmitri Shuralyov TryBot-Result: Gobot Gobot Reviewed-by: Alexander Rakoczy X-Tour-Commit: 8ec2108c3ab568fa335edadc5cd9a2c5ab5361ec --- tour/pic/pic.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tour/pic/pic.go b/tour/pic/pic.go index 21edae73..7f22edd4 100644 --- a/tour/pic/pic.go +++ b/tour/pic/pic.go @@ -1,7 +1,9 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// Copyright 2011 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 pic implements functions that +// display pictures on the Go playground. package pic // import "golang.org/x/tour/pic" import ( @@ -12,7 +14,16 @@ import ( "image/png" ) -func Show(f func(int, int) [][]uint8) { +// Show displays a picture defined by the function f +// when executed on the Go Playground. +// +// f should return a slice of length dy, +// each element of which is a slice of dx +// 8-bit unsigned int. The integers are +// interpreted as bluescale values, +// where the value 0 means full blue, +// and the value 255 means full white. +func Show(f func(dx, dy int) [][]uint8) { const ( dx = 256 dy = 256 @@ -32,6 +43,8 @@ func Show(f func(int, int) [][]uint8) { ShowImage(m) } +// ShowImage displays the image m +// when executed on the Go Playground. func ShowImage(m image.Image) { var buf bytes.Buffer err := png.Encode(&buf, m)