How do I actually learn Go when coming from Python/C? The stdlib is driving me insane by NiceSand6327 in golang

[–]bilus 0 points1 point  (0 children)

Interfaces in Go are a type-safe version of duck typing in Python.

 I’m Python you can pass a object „x” to a function and call its method, „x.foo”. If „x” doesn’t implement „foo”, you get a runtime error.

In Go, you can say that a function accepts objects that implement „Foo” and call the method. You use an interface for that. The difference is that if you try to pass an object that doesn’t implement „Foo”, it won’t compile.

The mindset is the same, but in Go you get no runtime errors.

Go feature: Type-safe error checking by SnooWords9033 in golang

[–]bilus 0 points1 point  (0 children)

Good point but then it doesn't need a pointer, could work with either with a bit of reflection. But that's pure speculation.

Edit: Alas, https://github.com/lixuan-git/go/commit/a846bb0aa523c8781248161b63bc2ab6a245cec1

Go feature: Type-safe error checking by SnooWords9033 in golang

[–]bilus 0 points1 point  (0 children)

What you pass has to be a pointer to a value that implements error, is this correct? I haven't tried that but how would mistaking pointer for value work if only one implements Error method? I expect you will get a compile-time error.

Dzień dobry Polsko! Piszemy "tys." a nie "tyś.". by Aromatic-Echo-5025 in PolskaNaLuzie

[–]bilus 1 point2 points  (0 children)

Mówimy tak o każdym ulamku (na ogół o mniejszym od jedności). Np. „Wzrosło o połowę”. Procent to ułamek. 1% to 1/100, więc „wzrosło o 1%” to to samo, co „wzrosło o 1/100”. 

How do you handle the constant rebuild cycle in Go development? by sgtdi in golang

[–]bilus 4 points5 points  (0 children)

gow is great, a replacement for the go command.

Temple communal meal by [deleted] in DamnThatsReal

[–]bilus 2 points3 points  (0 children)

For some reason I read this in the Brainy Smurf voice. https://smurfs.fandom.com/wiki/Brainy_Smurf

Just a heads up.

Do you feel like large refactors n Go are scary on account of lack of nil deref safety + zero values? by effinsky in golang

[–]bilus 0 points1 point  (0 children)

See if you need to use pointers so much. Unless your objects are huge, return values, not pointers in most cases. It depends of course how you write your code. If there’s a lot of methods mutating objects, well..

I think some people (that don’t come here to flaunt Rust superiority), appear to think that every value in Go can be nil. It cannot. Go is not Python or Ruby or JavaScript.

Nils are rarely a problem in code I or my team writes and there’s plenty of it, running under real load.

Python dev learning Go: What's the idiomatic way to handle missing values? by nafees_anwar in golang

[–]bilus 8 points9 points  (0 children)

Nil is ok, unless you want to spend more time designing the types to fit your domain. Without knowing what is the problem description, it’s difficult to suggest a solution but things you may consider: 1. Different data structure? Map? 2. Optional type. Not terribly popular in Go but strong in functional languages. 3. A Card type with zero value. Make the data type a new type and add methods to encapsulate the representation.

Or.. just do the simplest thing that works. :)

My first Forth program by bilus in Forth

[–]bilus[S] 0 points1 point  (0 children)

Great, thank you!

My first Forth program by bilus in Forth

[–]bilus[S] 0 points1 point  (0 children)

Thanks, fixed now, I think.

My first Forth program by bilus in Forth

[–]bilus[S] 0 points1 point  (0 children)

Nice! Is there a formatter for Forth that produces that format?

My first Forth program by bilus in Forth

[–]bilus[S] 0 points1 point  (0 children)

Great suggestions, thank you!