Your error comes from the spurious import of "treesort" in 
treesort_test.go.  (You are already inside package treesort; there is 
nothing to import)

With this line:

$ go test .
# example.com/blah
treesort_test.go:11:2: package treesort is not in GOROOT 
(/usr/local/go/src/treesort)
FAIL    example.com/blah [setup failed]
FAIL

Without this line: it works, once I've completed the code.

$ cat treesort_test.go
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/

package treesort

import (
        //"fmt"
        "math/rand"
        //"sort"
        "testing"
)

func TestSort(t *testing.T) {
        data := make([]int, 50)
        for i := range data {
                data[i] = rand.Int() % 50
        }
}

$ go test .
ok      example.com/blah    (cached)

On Thursday, 24 November 2022 at 19:09:18 UTC pat2...@gmail.com wrote:

> Sure 
>  
> cat treesort.go
>
> // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
> // License: https://creativecommons.org/licenses/by-nc-sa/4.0/
>
> // See page 101.
>
> // Package treesort provides insertion sort using an unbalanced binary 
> tree.
> package treesort
>
> // !+
> type tree struct {
>         value       int
>         left, right *tree
> }
>
>
> cat treesort_test.go
>
> // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
> // License: https://creativecommons.org/licenses/by-nc-sa/4.0/
>
> package treesort
>
> import (
>         "fmt"
>         "math/rand"
>         "sort"
>         "testing"
>         "treesort"
> )
>
> func TestSort(t *testing.T) {
>         data := make([]int, 50)
>         for i := range data {
>                 data[i] = rand.Int() % 50
>         }
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2891c58a-54c5-4ba3-a44c-1605f7c0330en%40googlegroups.com.

Reply via email to