Skip to main content
added 54 characters in body
Source Link

Instead of

i, ok := this.BoxItems[id]
if ok {
    i.Qty += qty
} 

a more idiomatic usage is

if i, ok := this.BoxItems[id]; ok {
    i.Qty += qty
} 

Calling the receiver this doesn't seem like a good practice to me. Calling it box would be clearer.

You seem to want to make your method chainable. I'm not sure this is a frequent practice in Go but it's probably more a matter of style and experience than a question of idiomatic code or not.

The rest could be condensed a little but that's not a matter of idiom. I have nothing to say regarding your use of pointers.

Instead of

i, ok := this.BoxItems[id]
if ok {
    i.Qty += qty
} 

a more idiomatic usage is

if i, ok := this.BoxItems[id]; ok {
    i.Qty += qty
} 

Calling the receiver this doesn't seem like a good practice to me. Calling it box would be clearer.

You seem to want to make your method chainable. I'm not sure this is a frequent practice in Go but it's probably more a matter of style and experience than a question of idiomatic code or not.

The rest could be condensed a little but that's not a matter of idiom.

Instead of

i, ok := this.BoxItems[id]
if ok {
    i.Qty += qty
} 

a more idiomatic usage is

if i, ok := this.BoxItems[id]; ok {
    i.Qty += qty
} 

Calling the receiver this doesn't seem like a good practice to me. Calling it box would be clearer.

You seem to want to make your method chainable. I'm not sure this is a frequent practice in Go but it's probably more a matter of style and experience than a question of idiomatic code or not.

The rest could be condensed a little but that's not a matter of idiom. I have nothing to say regarding your use of pointers.

Source Link

Instead of

i, ok := this.BoxItems[id]
if ok {
    i.Qty += qty
} 

a more idiomatic usage is

if i, ok := this.BoxItems[id]; ok {
    i.Qty += qty
} 

Calling the receiver this doesn't seem like a good practice to me. Calling it box would be clearer.

You seem to want to make your method chainable. I'm not sure this is a frequent practice in Go but it's probably more a matter of style and experience than a question of idiomatic code or not.

The rest could be condensed a little but that's not a matter of idiom.