attic-labs / noms

The versioned, forkable, syncable database
Apache License 2.0
7.44k stars 266 forks source link

Error following along with tutorial (bad URL parsing) #3781

Closed tobowers closed 6 years ago

tobowers commented 6 years ago

I was just trying to follow along with https://github.com/attic-labs/noms/blob/master/doc/go-tour.md and the following minimal code:

package main

import (
"fmt"
"os"

    "github.com/attic-labs/noms/go/spec"
)

func main() {
    sp, err := spec.ForDatabase("http://localhost:8000::people")
    if err != nil {
        fmt.Fprintf(os.Stderr, "Could not access database: %s\n", err)
        return
    }
    defer sp.Close()

    sp.GetDatabase()

}

produces the following error:

$ go run main.go 
        Error Trace:    try.go:99
                    try.go:44
                    http_chunk_store.go:501
                    http_chunk_store.go:423
                    http_chunk_store.go:84
                    http_chunk_store.go:62
                    spec.go:278
                    spec.go:165
                    main.go:27
                    proc.go:185
                    asm_amd64.s:2337
    Error:          Get http://localhost:8000::people/root/: invalid URL port "8000::people"

goroutine 1 [running]:
github.com/attic-labs/noms/go/d.PanicIfError(0x246c4e0, 0xc4205b8de0)
    /Users/tbowers/code/go/src/github.com/attic-labs/noms/go/d/try.go:44 +0x65
github.com/attic-labs/noms/go/datas.(*httpChunkStore).requestRoot(0xc4205d4120, 0x1c3c650, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x28b8458)
    /Users/tbowers/code/go/src/github.com/attic-labs/noms/go/datas/http_chunk_store.go:501 +0x1ac
github.com/attic-labs/noms/go/datas.(*httpChunkStore).getRoot(0xc4205d4120, 0xc420050300, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/tbowers/code/go/src/github.com/attic-labs/noms/go/datas/http_chunk_store.go:423 +0xc1
github.com/attic-labs/noms/go/datas.newHTTPChunkStoreWithClient(0xc420050300, 0x1d, 0x0, 0x0, 0x246be60, 0xc4205b8ab0, 0xc420050300)
    /Users/tbowers/code/go/src/github.com/attic-labs/noms/go/datas/http_chunk_store.go:84 +0x329
github.com/attic-labs/noms/go/datas.NewHTTPChunkStore(0xc420050300, 0x1d, 0x0, 0x0, 0x1, 0x1c5922f)
    /Users/tbowers/code/go/src/github.com/attic-labs/noms/go/datas/http_chunk_store.go:62 +0x96
github.com/attic-labs/noms/go/spec.Spec.createDatabase(0x1c5922a, 0x4, 0x1c5922f, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/tbowers/code/go/src/github.com/attic-labs/noms/go/spec/spec.go:278 +0xdc9
github.com/attic-labs/noms/go/spec.Spec.GetDatabase(0x1c5922a, 0x4, 0x1c5922f, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/tbowers/code/go/src/github.com/attic-labs/noms/go/spec/spec.go:165 +0x9f
main.main()
    /Users/tbowers/code/go/src/github.com/quorumcontrol/noms-play/main.go:27 +0x20b
exit status 2
tobowers commented 6 years ago

Running $ noms log http://localhost:8000::people produces similar error

aboodman commented 6 years ago

http://localhost:8000::foo specifies a dataset (the foo dataset of the database at http://localhost:8000).

But you used ForDatabase(), so that's an invalid database spec. The error message should be better sorry about that.

tobowers commented 6 years ago

Thank you! I didn't notice the difference in the two parts of the tutorial and only copied the bottom.