Wednesday 15 June 2011

go - Best practices, How to initialize custom types? -


I still do not have a way to work. Here I have Client Konqueror, which wraps Bidmap. How should I get started like this? So that I can add my bidimap adwords?

In my head it should look like this but all my solutions should look like 15 lines to avoid the blue pointer errors of code: D

  CC = create (Client Ccnaterpool) cc. Add code ("Foo", "bar")   

Code:

  Package main import () Type ClientConnectorPool struct {Name string connector list BidirMap} func ( C ClientConnectorPool Add key (key, val interface {}) {c.ConnectorList.Add (key, val)} Bidarmark structure {Add the left, right map [interface {}} interface {}} function (M-bitirmark) (key , Val interface {}) {if _, inbite: = mf [key]; Inleft {delete (m.left, key)} if _, inright: = m.right [val]; <{Code} 

You can not define for custom (actions) only () Work only on slices, maps, and channels (and custom types with those presentations).

Idiomatic Go will have a NewClientConnectorPool function (short in the NewPool ) which creates and returns.

  func NewPool (name string) ClientConnectorPool {return ClientConnectorPool {Name: Name, ConnectorList: BidirMap {left: make {map} {interface}} {}, correct: (map {interface} {}} {{}}}}}}   

You may also have a NewBidirMap function that covers the creation of that structure.

I do not know where you want to check for zero () will not return from zero, and the rest is a simple structure.

No comments:

Post a Comment