In my particular use case, I would like to know how the following Java code would be implemented in Go –
class Channel {
public String name;
public Channel(){}
}
ArrayList<Channel> channels = new ArrayList<Channel>();
I’ve gotten started, and I think this would be the appropriate struct for Channel in Go –
struct Channel {
name string
}
I just need to know how ArrayList would work in Go
Use a slice:
Also, your Channel declaration is slightly off, you need the ‘type’ keyword:
Here’s a complete example: http://play.golang.org/p/HnQ30wOftb
For more info, see the slices article.
There’s also the go tour (tour.golang.org) and the language spec (golang.org/ref/spec, see #Slice_types, #Slices, and #Appending_and_copying_slices).