c := getX()
c.x = 1
vs
getX().x = 1
On Wed, Nov 20, 2019 at 2:32 PM Robert Engels wrote:
> I must of misread something, because this code works fine:
>
> package main
>
> import "fmt"
>
> type X struct {
> x int
> }
>
> func getX() X {
> var x X
> return x
> }
>
> func main() {
>
I'm going to guess, based on the "break" statement in the final case, that
you expect each of the case statements without a break to fall through to
the nest case. Go does not work like that. By default, each case, whether
there's any action taken or not, breaks. Take a look at this to accomplish
w
Take a look at https://golang.org/cmd/nm/
On Sat, Jun 8, 2019 at 1:38 PM wrote:
> I'm looking for some type of tool or method to examine a compiled go
> binary and confirm that a list of functions is NOT included in the compiled
> binary.
>
> example:
> package internal
>
> func A() string {
>
> > Is this so bad?
>
> Yes, it's horrible as you'll loose any type information you had.
> Meaning the next thing you naturally had to do was type cast it, which
> isn't the nicest syntax to begin with.
> By then it's probably more work than just using if / else
>
So what you're saying is that G
Is this so bad?
func ternary(cond bool, pos, neg interface{}) interface{} {
if cond {
return pos
} else {
return neg
}
}
color := ternary( temp < 80, "blue", "red")
On Wed, Apr 24, 2019 at 4:14 PM Chris Broadfoot
wrote:
>
>
> On Wed, Apr 24, 2019 at 4:22 AM Robert Engels
> wrote:
>
If you add fmt.Println(runtime.NumCPU()), you'll see there's one CPU in the
playground environment. When main calls sleep after printing 0, the go
routine is ready to run, so it switches there, and prints 1. At that point,
when the go routine sleeps, main is not runnable (it's still sleeping), so
i