#go-nuts

/

      • owen1
        mayhew: got it. do i need to delete it or is it being deleted automaticaly?
      • dbasch has quit
      • snotra
        hfaafb, no, 1,4,2 would not pass
      • owen1
        mayhew: in my case it's a file that i only need temporarily. i have init.sql file with {{.User}} init.
      • joegalaxy71 has quit
      • mayhew: and i use the go template to inject the user/password into this file.
      • so it's a temporary file that i don't need to persist it after using it. so i thought of maybe using a temp file instead of regular file.
      • mayhew
        owen1: it's best practice to delete the temporary file when you no longer needed, but if you don't it will eventually be deleted by the system.
      • darkbolt has quit
      • someword has quit
      • cjhubert joined the channel
      • owen1
        mayhew: ok. so the only difference is the location of that file. other that that it's the same as regular file?
      • na_
        Does an array pointer type have to specify an array size?
      • FunnyLookinHat has quit
      • Can I write a function the takes a pointer to an arbitrarily-sized array and reverses the array?
      • mayhew
        owen1: yeah exactly, just a normal file! A lot of people mount /tmp with tmpfs which uses RAM to make it super fast and it doesn't persist on boot, some other systems will run cronjobs/init tasks to manually clean it up.
      • na_
        *that takes
      • jonmorehouse joined the channel
      • rafalo has quit
      • rafalo joined the channel
      • makaveli0227TL joined the channel
      • owen1
        mayhew: thank you
      • cschneid_ has quit
      • jonmorehouse joined the channel
      • firstdayonthejob joined the channel
      • Renich joined the channel
      • snotra
        kevlar, assuming no duplicates, if i am looking for COUNT consecutive numbers, wouldn't you just be able to do something like MAX_NUM-MIN_NUM+1=COUNT
      • jonmorehouse joined the channel
      • mperillo has quit
      • stuck-gopher has quit
      • daito joined the channel
      • na_
        Anyone?
      • datanoise joined the channel
      • dbasch joined the channel
      • owen1
        mayhew: it creates a file in my /tmp dir. but even though i have defer os.Remove(tmp.Name()) the file was not removed.
      • samw_ joined the channel
      • rik316 joined the channel
      • hydrajump
        can someone pls give feedback on this little function https://play.golang.org/p/WNIoN8SWkR
      • snotra
        kevlar, hfaafb --> http://play.golang.org/p/WIPtXmVUtF can you think of a better way to do it than this?
      • daito has quit
      • datanoise has quit
      • samw has quit
      • Lerg has quit
      • Falun` has quit
      • mayhew
        owen1: that's odd, I just tested this on my system and it worked fine - https://play.golang.org/p/5zmDL1-MJ-
      • Lerg joined the channel
      • Falun` joined the channel
      • d1str0 has quit
      • samw_ has quit
      • _sl has quit
      • vijaycs85 joined the channel
      • pkircher has quit
      • noethics joined the channel
      • na_: I believe arrays always include the number of elements, you probably want to use slices. Read this for a good overview: https://blog.golang.org/slices
      • pkircher joined the channel
      • FasTTo has quit
      • kevlar
      • basically the same code, just easier to read and write unit tests for.
      • netrino has quit
      • AlmogBaku has quit
      • iraj joined the channel
      • netrino joined the channel
      • jhadvig-afk has quit
      • snotra
        kevlar, what is this whole v-var thing about? i have never see that dash notation before
      • vildulv has quit
      • kevlar
        v-baseline?
      • snotra
        yeah
      • kevlar
        that's the mathematical difference between two numbers ;-)
      • snotra
        lol
      • hahaha
      • omg
      • snotra facepalm
      • it's been a long day apparently
      • mayhew
        to be fair, spaces between the variables and the - would probably be a better gofmt choice, but oh well
      • d1str0 joined the channel
      • ghounds joined the channel
      • na_
        Does an array pointer type have to specify an array size?
      • Lerg has quit
      • kn-928 has quit
      • eric_lagergren
        yeh gofmt groups order of operation
      • na_: pointers are typed so yes
      • Lerg joined the channel
      • *[50]byte != *[49]byte
      • the size of an array is part if its type.
      • na_
        I wonder why the size information extends to array pointer types
      • cronos has quit
      • kevlar
        snotra, this is a different algorithm, probably more efficient: http://play.golang.org/p/Mw0KtoQJoA
      • na_
        It wasn't necessary in C
      • hadsed_ has quit
      • Maybe so that len still works
      • eric_lagergren
        na_: because the size of an array is part of its type
      • kevlar
        snotra, oh, whoops, also broken; http://play.golang.org/p/cAZ2Mg_4Y_ is possibly better
      • mayhew
        na_: in C you have to pass the length to every function right?
      • na_
        mayhew: Depends on what you want to do
      • eric_lagergren
        na_: because the length is part of the array's type, [4]byte is a different type than [5]byet
      • na_: even though they're both arrays of bytes.
      • na_
        mayhew: C strings for example use a null byte to indicate the end of the string
      • eric_lagergren
        it's similar to how int32 is distinct from int, even on 32-bit platforms.
      • vijaycs85 has quit
      • tarrant
        Anyone have any tips on how to reduce time spent in runtime.findrunnable?
      • kevlar
        tarrant, fewer busy loops?
      • or maybe you're I/O bound
      • lqi joined the channel
      • tarrant
        I have a lot of threads that are waiting for a ticker, or channel write. Its kinda a fan-out & fan-in processing program.
      • kevlar
        so, what's the performance problem then?
      • tarrant
        During busy times of the day its not able to keep up with the load.
      • Renich has quit
      • Renich joined the channel
      • kevlar
        what are the tickers for then?
      • mayhew
        na_: yeah that's true but think about how many bugs were caused by the need to end arrays with NULL in C. We've got better type systems these days.
      • mohae
        ya, like JS
      • mohae ducks
      • kevlar
        we also have worse type systems
      • that's how we know some are better ;-)
      • tarrant
        There are several places where I have a select, one case is read off a channel and and aggregate, the second case is read from a ticker, send the processed sample to the next level.
      • Renich has quit
      • pawnbox joined the channel
      • kevlar
        tarrant, pipelines are not the best way to optimize in Go
      • mmalone joined the channel
      • tarrant
        cool, I'll look into removing some of them.
      • Renich joined the channel
      • na_
        ty
      • kevlar
        if you need to do batch processing, you can have one level of "batching" on the input side, but that should rarely be necessary
      • spawn a goroutine to process the entire request from start to finish
      • lqi has quit
      • (or the entire batch, if that turns out to be necessary)
      • mjcdiggity has quit
      • mohae
        there is the possibilty that the given workload is > than what the current system can handle
      • na_
        mayhew: It's convenient to define functions that work for any size array in C. Go has slices for this
      • kevlar
        remember that goroutines are way lighter-weight than threads, so you don't typically have to do the same kinds of contortions to minimize thread creation
      • alkama has quit
      • datanoise joined the channel
      • Renich has quit
      • tarrant
        yes I've thought about that and am working on sharing the work but currently it can't due to limitations in part of the system.
      • Renich joined the channel
      • foobaz
        lots of C code stores a length instead of using null-termination for arrays
      • rafalo has quit
      • it's strings that are typically null-terminated
      • Renich has quit
      • Renich joined the channel
      • kevlar
        tarrant, you might also want to consider using channel buffers as your batching mechanism
      • snotra
        okay, my brain is goo right now. been working too long today. what's the easiest way to remove a subslice from a larger slice?
      • mohae
      • kevlar
        read into your slice (that you reuse) until the read blocks, then process the batch, then try to read again
      • na_
        foobaz: See also argv
      • danhilly joined the channel
      • hadsed joined the channel
      • kevlar
      • julian-delphiki joined the channel
      • darkbolt joined the channel