Repository: exercism/xgo (go)

Issue:
variable-length-quantity: I don't think returning number of bytes decoded is necessary
Since it was introduced in #322, the decode function returns the number of bytes decoded. The creator of the exercise mentioned that it was to be consistent with the standard library's API. I am not sure right now, but I guess it would be something similar to https://golang.org/pkg/io/#Writer or something?

Now, since #674, it is required that the entire input array be decoded, or else it is an error. I would say now that the number of bytes to decode doesn't make much sense to return, since now it is known that it will always be the length of the input array. If you want an standard library example, https://golang.org/pkg/encoding/json/#Unmarshal doesn't return number of bytes decoded.

I will probably do this myself in a little over 24 hours but can't now, so it's a reminder for me to do.

Pull request description:
variable-length-quantity: Decode: don't return/test length
Since it was introduced in #322, the decode function returns the number
of bytes decoded. The creator of the exercise mentioned that it was to
be consistent with the standard library's API.

Go standard library example for returning number of bytes:
https://golang.org/pkg/io/#Writer

Now, since #674, it is required that the entire input array be decoded,
or else it is an error. Now the number of bytes decoded doesn't make
much sense to return, since now it is known that it will always be the
length of the input.

Go standard library example for not returning number of bytes (decoding
everything):
https://golang.org/pkg/encoding/json/#Unmarshal

testVersion -> 4

Closes #683

Patch:
diff --git a/LICENSE b/LICENSE
index 0dc403e5..eee993a5 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
-The MIT License (MIT)
+MIT License
 
-Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
+Copyright (c) 2017 Exercism, Inc
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 56dc175c..5ff3329b 100644
--- a/README.md
+++ b/README.md
@@ -243,11 +243,6 @@ for clues.  Usually error messages will be helpful and you can correct the probl
 Directions are unlimited.  This code is fresh and evolving.  Explore the existing code and you will see some new
 directions being tried.  Your fresh ideas and contributions are welcome.  :sparkles:
 
-## License
-
-The MIT License (MIT)
-
-Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
 
 ### Go icon
 The Go logo was designed by Renée French, and has been released under the Creative Commons 3.0 Attributions license.
diff --git a/exercises/variable-length-quantity/.meta/gen.go b/exercises/variable-length-quantity/.meta/gen.go
index 5b71a941..3cf7580f 100644
--- a/exercises/variable-length-quantity/.meta/gen.go
+++ b/exercises/variable-length-quantity/.meta/gen.go
@@ -11,7 +11,6 @@ func main() {
 	t := template.New("").Funcs(template.FuncMap{
 		"GroupComment": GroupComment,
 		"byteSlice":    byteSlice,
-		"lengthSlice":  lengthSlice,
 	})
 	t, err := t.Parse(tmpl)
 	if err != nil {
@@ -32,11 +31,6 @@ func byteSlice(ns []uint32) []byte {
 	return b
 }
 
-// lengthSlice returns the length of given slice.
-func lengthSlice(ns []uint32) int {
-	return len(ns)
-}
-
 // The JSON structure we expect to be able to unmarshal into
 type js struct {
 	Groups []TestGroup `json:"Cases"`
@@ -101,13 +95,11 @@ var decodeTestCases = []struct {
 	description string
 	input	[]byte
 	output	[]uint32 // nil slice indicates error expected.
-	size int
 }{ {{range .J.Groups}} {{range .Cases}}
 	{{if .PropertyMatch "decode"}} {
 		{{printf "%q" .Description}},
 		{{byteSlice .Input | printf "%#v" }},
 		{{printf "%#v" .Expected }},
-		{{lengthSlice .Input}},
 	},{{- end}}{{end}}{{end}}
 }
 `
diff --git a/exercises/variable-length-quantity/example.go b/exercises/variable-length-quantity/example.go
index 530cd075..bd724eed 100644
--- a/exercises/variable-length-quantity/example.go
+++ b/exercises/variable-length-quantity/example.go
@@ -2,7 +2,7 @@ package variablelengthquantity
 
 import "errors"
 
-const testVersion = 3
+const testVersion = 4
 
 var ErrUnterminatedSequence = errors.New("unterminated sequence")
 
@@ -83,19 +83,19 @@ func EncodeVarint(xa []uint32) []byte {
 // DecodeVarint decodes a buffer of var-int encoded values into
 // a slice of uint32 values; an error is returned if buf doesn't
 // decode var-int successfully.
-func DecodeVarint(buf []byte) (ra []uint32, n int, err error) {
+func DecodeVarint(buf []byte) (ra []uint32, err error) {
 	if len(buf) == 0 {
-		return []uint32{0}, 1, nil
+		return []uint32{0}, nil
 	}
 	usedBytes := 0
 	ra = make([]uint32, 0)
 	for usedBytes < len(buf) {
 		r, nUsed, err := decodeInt(buf[usedBytes:])
 		if err != nil {
-			return nil, usedBytes, err
+			return nil, err
 		}
 		ra = append(ra, r)
 		usedBytes += nUsed
 	}
-	return ra, usedBytes, nil
+	return ra, nil
 }


Test patch:
diff --git a/exercises/variable-length-quantity/cases_test.go b/exercises/variable-length-quantity/cases_test.go
index d4026fab..d4d8c7b2 100644
--- a/exercises/variable-length-quantity/cases_test.go
+++ b/exercises/variable-length-quantity/cases_test.go
@@ -107,55 +107,46 @@ var decodeTestCases = []struct {
 	description string
 	input       []byte
 	output      []uint32 // nil slice indicates error expected.
-	size        int
 }{
 
 	{
 		"one byte",
 		[]byte{0x7f},
 		[]uint32{0x7f},
-		1,
 	},
 	{
 		"two bytes",
 		[]byte{0xc0, 0x0},
 		[]uint32{0x2000},
-		2,
 	},
 	{
 		"three bytes",
 		[]byte{0xff, 0xff, 0x7f},
 		[]uint32{0x1fffff},
-		3,
 	},
 	{
 		"four bytes",
 		[]byte{0x81, 0x80, 0x80, 0x0},
 		[]uint32{0x200000},
-		4,
 	},
 	{
 		"maximum 32-bit integer",
 		[]byte{0x8f, 0xff, 0xff, 0xff, 0x7f},
 		[]uint32{0xffffffff},
-		5,
 	},
 	{
 		"incomplete sequence causes error",
 		[]byte{0xff},
 		[]uint32(nil),
-		1,
 	},
 	{
 		"incomplete sequence causes error, even if value is zero",
 		[]byte{0x80},
 		[]uint32(nil),
-		1,
 	},
 	{
 		"multiple values",
 		[]byte{0xc0, 0x0, 0xc8, 0xe8, 0x56, 0xff, 0xff, 0xff, 0x7f, 0x0, 0xff, 0x7f, 0x81, 0x80, 0x0},
 		[]uint32{0x2000, 0x123456, 0xfffffff, 0x0, 0x3fff, 0x4000},
-		15,
 	},
 }
diff --git a/exercises/variable-length-quantity/variable_length_quantity_test.go b/exercises/variable-length-quantity/variable_length_quantity_test.go
index bee3e7b5..786546fb 100644
--- a/exercises/variable-length-quantity/variable_length_quantity_test.go
+++ b/exercises/variable-length-quantity/variable_length_quantity_test.go
@@ -6,7 +6,7 @@ import (
 	"testing"
 )
 
-const targetTestVersion = 3
+const targetTestVersion = 4
 
 func TestTestVersion(t *testing.T) {
 	if testVersion != targetTestVersion {
@@ -16,7 +16,7 @@ func TestTestVersion(t *testing.T) {
 
 func TestDecodeVarint(t *testing.T) {
 	for i, tc := range decodeTestCases {
-		o, size, err := DecodeVarint(tc.input)
+		o, err := DecodeVarint(tc.input)
 		if err != nil {
 			var _ error = err
 			if tc.output != nil {
@@ -26,8 +26,6 @@ func TestDecodeVarint(t *testing.T) {
 			t.Fatalf("FAIL: case %d | %s\nexpected error, got %#v\n", i, tc.description, o)
 		} else if !reflect.DeepEqual(o, tc.output) {
 			t.Fatalf("FAIL: case %d | %s\nexpected\t%#v\ngot\t\t%#v\n", i, tc.description, tc.output, o)
-		} else if size != tc.size {
-			t.Fatalf("FAIL: case %d | %s\n expected encoding size of %d bytes\ngot %d bytes\n", i, tc.description, tc.size, size)
 		}
 		t.Logf("PASS: case %d | %s\n", i, tc.description)
 	}