You can't use dict in golang like you would in python. There's no equivalent in golang. Sorry.

There's no key value datasets in golang? Lol. Guess I have to use SQL.

i don't know why but only gopher out of programming mascots has this unspoken rizz.

this ain't some tranny crab or diseased rat, this fucking motherfucker is stealing your codebase for sure

>>93059474 (OP)

>There's no equivalent in golang

map[any]any

>>93059474 (OP)

Yes you can anon!

You can use a struct with

type meme struct {

    foo string,

    bar string,

}



if you want to add and remove properties arbitrarily, you can use

var meme map[string]string

meme = map[string]string{

    "foo": "bar",

    "bar": "foo",

}



or in the case you need extreme flexibility, (although you probably don't need this and you're better off not using it), you can use:

var meme map[interface{}]interface{}



an interface to interface map would allow you to use anything as a key and store anything inside it.

How do I do this python code in golang?

A = {}

A[1] = 1

A["nig"] = "ger"

>>93059474 (OP)

Can't you just use a struct? It's basically Python's dataclass, and Python's dataclass is a fancy dictionary with functions.

thread ended here idiots >>93059594

a := map[any]any{}

a[1] = 1

a["nig"] = "ger"



>map

>No contains method

Fail.

You don't need it in go. []operator returns 2 values: value and bool, which is an indicator if the key exists or not

Maps in Go and Dicts in Python are both hashmap datastructures.

Also, if you can't make a hashmap yourself just stop programming because you're dumb.

>>93059474 (OP)

>python just added switch statement after 30 years

fucking sad, honestly

>>93059474 (OP)

No other Go thread so I will vent here. After moving to Rust I can finally understand what everyone is complaining about with Go error handling. This:



if err != nil {

return err

}

if err != nil {

return err

}

if err != nil {

return err

}

if err != nil {

return err

}



Is literally just this in Rust:



?



I cannot believe how simple it is and how much more ergonomic and clean it is. I've gone from viewing Go as the "holy" language to just another language that corps will force people to use because it is in fashion.

Everyone bitches about this but it's just explicit program flow. It also makes it easier than other languages because you know exactly where your code can throw an error. At the very least it's better than try catch finally bullshit, where you just have to know what could throw and error. While it results in good code, it is tedious, though.

Nooooo! It has to be like map[Comparable]any. You are wrong dude!

I use both languages, both are nice, your example is retarded.

Rust's question mark operator returns the error automatically. Still explicit, still visible, but instead of three lines it's a single character.

if _, ok := a["nig"]; ok {

    fmt.Println("a contains nig")

}



>>93059474 (OP)

>retard doesn't know about maps in Go >>93059594

>creates bait thread for other retards to spoonfeed him

>retards spoonfeed the OP

this is such an obvious tech support thread...

report it, retards.

I know it is explicit code flow, I like explicit code flow, but my point is that you can have explicit code flow in Rust without the retarded repetitive Go syntax. They are both explicit.

My example is just fine. Everyone complains about it. You are the retard here. Not a single person on Earth will prefer Go error handling over Rust.
