[go-nuts] Re: various odd, to me, at best undocumented, behaviour of automatic formatting in go doc

2017-11-21 Thread Volker Dobler
On Tuesday, 21 November 2017 21:26:56 UTC+1, simon place wrote: > > see; > > https://play.golang.org/p/kPWJzm1rQi > > see comments for details, found more than i banked on whilst investigating > a formatting issue on GitHub docs (turned out to be example 7.). > Just some thoughts and my

Re: [go-nuts] Union types mindset

2017-11-21 Thread 'Paulo Matos' via golang-nuts
Josh, Thanks for the quick and clear reply. I was not aware of the dual return form of type conversion. Paulo Matos On 21/11/17 00:05, Josh Humphries wrote: > Hi, Paulo, > I think you're on the right track. The main thing to note is that the > IsInstruction method isn't that useful. A concrete

[go-nuts] Re: stucked in the interface mud

2017-11-21 Thread christian . b . mueller
Thank you very much for you replies. 1. Yes, I wanted to avoid type switches (in different modules). 2. "myType" is a placeholder for more complex types, and the type "Compare" is only the the first in a row. The goal is some kind of a "contain" operation over lists of different objects (thats

[go-nuts] Re: Union types mindset

2017-11-21 Thread howardcshaw
In addition to Joshua's suggestion, I would point to Composition. Something like this: // Anything with a GetComment implicitly implements this Interface type AsmComment interface { GetComment() string // presuming any line could have a comment } type AsmEntry interface {

Re: [go-nuts] Union types mindset

2017-11-21 Thread roger peppe
Also check out type switches: https://golang.org/ref/spec#Type_switches On 21 November 2017 at 08:18, 'Paulo Matos' via golang-nuts wrote: > Josh, > > Thanks for the quick and clear reply. I was not aware of the dual return > form of type conversion. > > Paulo

[go-nuts] stucked in the interface mud

2017-11-21 Thread christian . b . mueller
hi there, and first of all sorry that i couldn't find the answer by myself here. I tried to improve some of my code with general interface definitions. They should work like macros for different types of variables. Here is my reduced example and the question - how should this be done in go the

Re: [go-nuts] stucked in the interface mud

2017-11-21 Thread Jan Mercl
On Tue, Nov 21, 2017 at 2:40 PM wrote: https://play.golang.org/p/InPAO_haLU works, but I don't think it's what you're after, because once more types implement Compare this approach gets dirty with type too many type switches. -- -j -- You received this message

Re: [go-nuts] stucked in the interface mud

2017-11-21 Thread 'Axel Wagner' via golang-nuts
This question is frequently asked . In short: Because the arguments to myType.Less have to be of type Compare, not myType. Go does not have polymorphic types. To answer the "how should this be done in Go the right way": IMO the answer is "not".

[go-nuts] Re: Decode as JSON and store the JSON as blob in DB

2017-11-21 Thread Nathan Kerr
I think what was meant was to define Service as: type Service struct { ID string `json:"id,omitempty" db:"id"` Name string `json:"name" db:"name"` Contract json.RawMessage `json:"contract" db:"contract"` } This assumes you don't need to access the contents of Service.Contract and they

[go-nuts] Re: stucked in the interface mud

2017-11-21 Thread christian . b . mueller
Thank you very much, for your replies. I think noe I maybe understand the problem a lot better. 1. Yes I wanted to avoid type switches, escpacially in different modules. 2. "myType" ist a placeholder for a complext struct, and the comparison operators are only the basics. The goal are "contain"

[go-nuts] Re: C like macros in golang

2017-11-21 Thread recolickeghart
I believe it's useful to write a preprocessor for golang. And run it before every go compilation. So that I'll be happy to feed myself C++-style golang. 在 2013年2月23日星期六 UTC+8下午10:20:34,Tong Sun写道: > > Hi, > > Expressed in C macros, I'd like to define something like this: > > #define

Re: [go-nuts] is this safe?

2017-11-21 Thread Jan Mercl
On Tue, Nov 21, 2017 at 7:51 PM DV wrote: > I think that's a horrible idea in any language, honestly. You shouldn't be mutating the thing you're enumerating. Go specs, for example, take care to guarantee it's safe in at least some, if not all cases. Pruning eg. a

[go-nuts] is this safe?

2017-11-21 Thread DV
I think that's a horrible idea in any language, honestly. You shouldn't be mutating the thing you're enumerating. -- 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

[go-nuts] various odd, to me, at best undocumented, behaviour of automatic formatting in go doc

2017-11-21 Thread 'simon place' via golang-nuts
see; https://play.golang.org/p/kPWJzm1rQi see comments for details, found more than i banked on whilst investigating a formatting issue on GitHub docs (turned out to be example 7.). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Re: Efficient to copy Hash?

2017-11-21 Thread 'simon place' via golang-nuts
i found this code, and use it on hash.Hash // copy an interface value using reflect (here for pointers to interfaces) func clone(i interface{}) interface{} { indirect := reflect.Indirect(reflect.ValueOf(i)) newIndirect := reflect.New(indirect.Type())

[go-nuts] Re: is this safe?

2017-11-21 Thread Albert Tedja
You need to swap elements if you want to remove them from list while iterating it. There are two ways to do this: First: iterate backward. This will however, will change the order of unremoved elements. Second: iterate forward, and will preserve the order of the unremoved elements.

[go-nuts] Re: How to download a compressed S3 object ? example ( abc.zip )

2017-11-21 Thread Alex Buchanan
Here's some example s3 client code we use in Funnel: https://github.com/ohsu-comp-bio/funnel/blob/master/storage/s3.go And Amazon's S3 client docs: https://godoc.org/github.com/aws/aws-sdk-go/service/s3#hdr-Download_Manager Or, if you meant non-Amazon s3, we have some experience with minio: