How to use container/vector (and similar)

788 views
Skip to first unread message

Seth Hoenig

unread,
Apr 10, 2010, 2:49:17 AM4/10/10
to golang-nuts
I know this should be extremely trivial, but I can't find an example
of how to do this anywhere:

// Container Test

package main
import "fmt"
import "container/vector"

func main() {
fmt.Printf("Hello Container Test\n");
//var v vector;
v := new(vector);
v.Push(4);
fmt.Printf("top: %d\n", v.Pop());
}

Both "var v vector" and "v:=new vector" give the errors:
cont.go:5: imported and not used: vector
cont.go:10: use of package vector not in selector

So how is one supposed to use something like container/vector?

chris dollin

unread,
Apr 10, 2010, 3:08:36 AM4/10/10
to Seth Hoenig, golang-nuts
On 10 April 2010 07:49, Seth Hoenig <seth.a...@gmail.com> wrote:
I know this should be extremely trivial, but I can't find an example
of how to do this anywhere:

// Container Test

package main
import "fmt"
import "container/vector"

func main() {
 fmt.Printf("Hello Container Test\n");
 //var v vector;
 v := new(vector);

var v vector.Vector
 
 v.Push(4);
 fmt.Printf("top: %d\n", v.Pop());
}

Both "var v vector" and "v:=new vector" give the errors:
cont.go:5: imported and not used: vector

You had imported the package "vector", but never
(properly) referenced it.
 
cont.go:10: use of package vector not in selector

Your one (mis-) use of vector, which is a package name,
wasn't as something being selected from.
 
--
Chris "allusive" Dollin
Reply all
Reply to author
Forward
0 new messages