Browse Source

Fix comments, apply gofmt.

Dmitry Chestnykh 14 years ago
parent
commit
4572d7de1e
5 changed files with 8 additions and 11 deletions
  1. 1 2
      audio.go
  2. 5 6
      captcha.go
  3. 1 1
      generate/main.go
  4. 0 1
      image.go
  5. 1 1
      sounds.go

+ 1 - 2
audio.go

@@ -13,9 +13,8 @@ import (
 const sampleRate = 8000 // Hz
 
 var (
-	// Length of the longest digit sound.
 	longestDigitSndLen int
-	endingBeepSound  []byte
+	endingBeepSound    []byte
 )
 
 func init() {

+ 5 - 6
captcha.go

@@ -11,10 +11,10 @@ import (
 const (
 	// Standard number of digits in captcha.
 	StdLength = 6
-	// The number of captchas created that triggers garbage collection
+	// The number of captchas created that triggers garbage collection.
 	StdCollectNum = 100
-	// Expiration time of captchas
-	StdExpiration = 2*60 // 2 minutes
+	// Expiration time of captchas.
+	StdExpiration = 2 * 60 // 2 minutes
 
 )
 
@@ -28,7 +28,7 @@ var globalStore = newStore(StdCollectNum, StdExpiration)
 func RandomDigits(length int) []byte {
 	d := make([]byte, length)
 	if _, err := io.ReadFull(rand.Reader, d); err != nil {
-		panic(err)
+		panic("error reading random source: " + err.String())
 	}
 	for i := range d {
 		d[i] %= 10
@@ -99,8 +99,7 @@ func Verify(id string, digits []byte) bool {
 // generated captchas, but still exported to enable freeing memory manually if
 // needed.
 //
-// Collection is launched in a new goroutine, so this function returns
-// immediately.
+// Collection is launched in a new goroutine.
 func Collect() {
 	go globalStore.collect()
 }

+ 1 - 1
generate/main.go

@@ -67,7 +67,7 @@ func main() {
 	}
 	defer pcm.Close()
 	fmt.Fprintf(pcm, `package captcha
-		    
+
 // This file has been generated from .wav files using generate.go.
 
 var waveHeader = []byte{

+ 0 - 1
image.go

@@ -40,7 +40,6 @@ func NewImage(digits []byte, width, height int) *Image {
 		uint8(rand.Intn(129)),
 		0xFF,
 	}
-	// Calculate sizes.
 	img.calculateSizes(width, height, len(digits))
 	// Draw background (10 random circles of random brightness).
 	img.fillWithCircles(10, img.dotSize)

+ 1 - 1
sounds.go

@@ -1,5 +1,5 @@
 package captcha
-		    
+
 // This file has been generated from .wav files using generate.go.
 
 var waveHeader = []byte{