#go-nuts

/

      • bartuka joined the channel
      • alrs joined the channel
      • sh3iny joined the channel
      • cruxeter is now known as cruxeternus
      • Spritzgebaeck has quit
      • nekoseam
        So I'm only allowed to run "go install (file)" when the file is named after the directory its in? e.g. if a file is named "test" inside a directory called "moo" go will complain that it cant find the file in /home/user/test/
      • keepguessing
        nekoseam: give your command you are trying in this example.
      • Tv`
        nekoseam: go works on packages, not files; let it do that
      • Spritzgebaeck joined the channel
      • Xionkana joined the channel
      • inhortte joined the channel
      • addos has quit
      • nekoseam
        hold up I figured it out
      • madorn has quit
      • sedeki joined the channel
      • kajo has quit
      • pkircher joined the channel
      • kajo joined the channel
      • TripleDES joined the channel
      • bartuka has quit
      • LEI joined the channel
      • hitchnsmile joined the channel
      • hitchnsmile
        Greetings!
      • iAmerikan has quit
      • LEI
        Bonsoir?
      • I have a hard time with pointers in general.. would they have any utility to in this snippet https://play.golang.org/p/vLtcvwjrPjd for example? I initially used []*Input and it caused some trouble.
      • sedeki
        if you want to reference one unique instance of something, you can only do it with a pointer
      • bpalmer
        LEI: let me guess: if you use with *Input, you get all the same character?
      • LEI
        obviously yes :P how to use it properly then, I will read the docs again but I would like to "reallocate" the slice
      • bpalmer
        LEI: a pointer points at a place in memory. If you keep re-using the same pointer but changing the value in memory, everything that points there will see the last value in memory
      • b0nn
        LEI: Values are copies of something, pointers are dealing with the original something
      • bpalmer
        LEI: in your SplitChars, if it's a *Input, you'll keep changing that one place in memory.
      • sedeki has quit
      • LEI
        what I don't get is shouldnt it be a slice of pointers
      • once looped I assign the same pointer all over again?
      • onorua joined the channel
      • maybe I should try *[]Input?
      • onorua has quit
      • I should have started learning with C u_u
      • bpalmer
        LEI: every time you have a pointer, you can use %p with fmt.Printf to see where it's pointing at. If two different pointers have the same address, they're pointing at the same object
      • LEI
        bpalmer: I think I got that, but I will experiment with incrementally complex structure (meaning slices then structs) to wrap my head around it
      • b0nn
      • lines 33 and 34 needed to be addresses not values
      • although it's a really convoluted and hgorrible example
      • LEI
        yes I didn't start simple on this one
      • b0nn
        When I first learnt about pointers and references I thought about URLS, a URL is a pointer to a resource on the internet, and when we dereference it we get a copy of that resource onto our computers
      • bpalmer
        I'm not a fan of types that are slices (really, I'm skeptical of anything that might mask pointer-like behavior)
      • slices, maps, what-have-you
      • killer_snail joined the channel
      • LEI
        bpalmer: yep I added it to switch between [] and []* in the example, there might be no good reason to do that
      • b0nn: thanks, the concept of addresses is clear on paper, but how do you "address" variable and not values in Go? I can't find what to tweak in the snippet ><
      • inhortte has quit
      • Pulp joined the channel
      • bartuka joined the channel
      • b0nn
        So, part of the problem is the * operator is overloaded
      • *P int means "Pointer to an int" but a := *P means "get the value pointed to by *P"
      • whereas &P means "Get me the address of P"
      • davr0s has quit
      • KirkMcDonald
        As an operator, it has exactly one meaning: It dereferences a pointer.
      • As a type modifier, it has another meaning: A pointer to a given type.
      • pkircher_ joined the channel
      • pkircher has quit
      • LEI
        b0nn: with trial and error I start to understand thos
      • b0nn
        It has two meanings, that ios the definition of overloading, the contexts is how you decide which of the overloaded meaning applys
      • LEI
        but there is yet another failed attemp https://play.golang.org/p/n7NooPOEsY_X
      • KirkMcDonald
        (Of course, * has a third meaning, when used as a binary operator.)
      • b0nn
        LEI: I think a better approach would be to divest yourself of this convoluted example, until you have a clear understanding of Pointers
      • patientplatypus joined the channel
      • Unless you're married to it for some reason (eg. homework)
      • LEI
        b0nn: not even, thanks for the hints :)
      • patientplatypus
        hi guys
      • If anyone has any ideas on how to solve this (seemingly simple) cors problem please let me know
      • its very frustrating
      • graphene joined the channel
      • b0nn
        LEI: As I said earlier, I came to understand pointers and references by thinking of them as URLS, the URL is the address of the resource, when I point my browser to that resource with that address I get the value stored at that URL
      • The browser has a copy of the resource held at the URL, and if I change it in my browser I only affect my local copy, but if I change the value at the server end then I change what people get when they access that URL
      • jiuweigui has quit
      • bpalmer
        patientplatypus: where do you associate your mux with the http server?
      • graphene joined the channel
      • jfoy has quit
      • graphene has quit
      • jfoy joined the channel
      • graphene joined the channel
      • patientplatypus
        @bpalmer https://www.alexedwards.net/blog/a-recap-of-req... - newServeMux should just work with HandleFunc I think
      • pkircher joined the channel
      • bpalmer
        patientplatypus: you're passing in nil
      • not the object you painstakingly created.
      • patientplatypus
        sorry im not seeing it
      • ah
      • ok - well if i pass in the handler how does it handle more than one handlefunc
      • ?
      • bpalmer
        patientplatypus: it passes it on; see the example on the cors documentation
      • Kvasya has quit
      • patientplatypus
        you see in the example that rs/cors has they can only pass in one route - how do i do multiple?
      • __charly__ joined the channel
      • bpalmer
        patientplatypus: cors.Default().Handler(mux) <-- handles a lot, and then passes requests on to the passed-in mux
      • davr0s joined the channel
      • patientplatypus
        ahhhh
      • let me try one sec
      • yeah no that doesnt work - same error
      • bpalmer
        what's your new code?
      • patientplatypus
      • alrs has quit
      • Emperor_Earth joined the channel
      • bpalmer
        Hmm. OK, looks plausible
      • patientplatypus
        yeah i have no idea at this point
      • LEI
        b0nn: I got it now, wasn't rocket science! just one star away...
      • patientplatypus
        well i guess its an open question for the moment then
      • bartuka has quit