[go-nuts] Experience Report building OCR in Go

2018-01-15 Thread Kevin Malachowski
Not sure about the GUI points: exp/shiny has worked really well for me and has existed for at least a year. I do admit that 4 years ago I tried my hand at a GUI framework for Go though... -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsub

[go-nuts] Re: JSON and Embedded Types (Aliases)

2018-01-21 Thread Kevin Malachowski
Given the last playground post, I'd guess that the aliased type (i.e. 'int' here) is being used for visibility rather than the alias's new name. It's also a little weird to use embedded types that dont need to be (there's no method promotion here because 'int' has no methods), or seeing aliases

[go-nuts] A string with zero ptr and cause SIGSEGV

2018-01-28 Thread Kevin Malachowski
Try running the code with the race detector (compile with -race), mysterious crashes are usually caused by data races. It's weird that it would happen with a string parameter to a function though. Are you using multiple goroutines in that function to modify/access a string? Can you share the co

[go-nuts] Is it possible to determine total number of bytes read/written for an HTTP request? (including headers)

2018-01-28 Thread Kevin Malachowski
Given TCP connection reuse I don't think the os/kernel will be able to tell apart the TCP connections any better than intercepting the net.Conn with a custom listener. Especially if you're using anything encrypted, staying in Go is going to be necessary for you to get the sort of data you need.

[go-nuts] Re: Tweaking sync.Pool for mostly-empty pools

2018-02-15 Thread Kevin Malachowski
If there is likely nothing in the Pool, then maybe it's better to not use one at all. Can you compare the internal workload with an implementation where all callers just call the `New` function directly? What's the purpose of using a pooled memory if there's often nothing in the pool? On Wednes

[go-nuts] Silent errors during template execution

2018-03-24 Thread Kevin Malachowski
Can you post a minimal (but compilable and runnable) example which shows exactly what isn't working? You can create and share this conveniently using play.golang.org. Creating a small, self-contained example is helpful in that it helps us see exactly what isn't working, and can be helpful to yo

Re: [go-nuts] Why "strings" package exists ?

2018-08-15 Thread Kevin Malachowski
Well, the 'error' type has a method. But none of the other primitives do. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com

[go-nuts] Q on using reflect: how to distinguish methods from functions?

2018-12-14 Thread Kevin Malachowski
Why do you need to figure out whether something is a Method? Usually it doesn't really matter. (I don't have an answer for you, but if you give more background I or someone else may be able to be more useful; trying to avoid the X-Y problem.) -- You received this message because you are subscr

[go-nuts] testing code that uses ioutil.ReadDir?

2020-04-12 Thread Kevin Malachowski
Is there a particular reason you want 100% code coverage? Not trying to start a flame war: given limited time and effort, unless the rest of my projects had 100% coverage already, I would personally spend my time working with a package with lower coverage, or just fixing known bugs. If your cod

[go-nuts] Who Loves Go?

2016-08-14 Thread Kevin Malachowski
I do! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Re: [go-nuts] Create methods for structs at runtime

2017-06-14 Thread Kevin Malachowski
Maybe I'm missing something obvious, but why do you need to do this? Seems like some sort of remote dependency injection which requires you to serialize code from the server to the client. Why not just release a compiled client binary which has all of the implementations compiled in already, and

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread Kevin Malachowski
It's best to compare the assembly, but my guess: 'make' has to zero out the memory, whereas allocation using append does not. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send

Re: [go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread Kevin Malachowski
But memclr+copy is slower than just copy, right? On Jun 27, 2017 6:53 PM, "T L" wrote: > > > On Tuesday, June 27, 2017 at 8:55:48 PM UTC-4, Kevin Malachowski wrote: >> >> It's best to compare the assembly, but my guess: 'make' has to zero out >&

Re: [go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread Kevin Malachowski
Hit send too early... Your benchmarks do show that something is strange hen comparing the make (memclr) and copy (memory copy) cases. Out of my element here :) On Jun 27, 2017 7:01 PM, "Kevin Malachowski" wrote: > But memclr+copy is slower than just copy, right? > > On Jun 2

Re: [go-nuts] Maximum number of requests per HTTP connection?

2017-07-05 Thread Kevin Malachowski
Creating an http.RoundTripper which was in charge of delegating to an http.Transport as well as swapping out to a new http.Transport when you want to swap underlying connections is probably what I'd try first. Cleaning up the old transport might be a little tricky if your application ever leaks

[go-nuts] Initializing aliased map

2017-07-07 Thread Kevin Malachowski
Note that the zero value of "aliased" is "nil". If you meant "an empty, newly initialized value" then, as previously mentioned, `make(aliased)` will do it for you, as would `aliased{}`. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubsc

[go-nuts] Do you check in vendor packages?

2017-09-14 Thread Kevin Malachowski
I generally vote for checking in, or at least ensuring that /something/ has an in-house copy of all dependencies. The worst thing that can happen is someone deleting their repository and having your project being super broken. (See also https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos

[go-nuts] Re: What is the best way to represent functional options within factory methods?

2017-10-11 Thread Kevin Malachowski
Why do you need all of your factories to have a common parameter? Also, what problem are you trying to solve? If you're just trying to organize your code, to what end are you pursuing this generalization? That is, what would you like your final code to look like? (Feel free to use psuedocode to

[go-nuts] Re: Why are can't struct field types not be used as types

2017-12-10 Thread Kevin Malachowski
Why not name the inner type? https://play.golang.org/p/8hyMLUVbCp -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For mo

Re: [go-nuts] Re: Q about defer

2021-12-24 Thread Kevin Malachowski
Actually, this part is a bit more relevant: "That is, if the surrounding function returns through an explicit return statement, deferred functions are executed after any result parameters are set by that return statement but before the function returns to its caller." On Fri, Dec 24, 2021, 12:50

Re: [go-nuts] go runtime/stubs.go noescape

2019-10-15 Thread Kevin Malachowski
I believe the question was about the specific implementation of noescape, specifically the "exclusive or" in that unsafe expression. To the original poster: are you just curious why, or is there a more specific question you have? I'm assuming that function looks like that to correctly trick the

[go-nuts] Re: [64]byte()[:]

2019-11-16 Thread Kevin Malachowski
"make"ing a byre slice every time you call Equal is not likely as efficient; surely it will put pressure on the garbage collector, assuming it's not just called a few times. Writing something in less lines is not strictly better. I'd probably just make package level variable and reuse it among

Re: [go-nuts] Re: [64]byte()[:]

2019-11-17 Thread Kevin Malachowski
n Sun, Nov 17, 2019 at 1:00 AM Kevin Malachowski > wrote: > >> "make"ing a byre slice every time you call Equal is not likely as >> efficient; surely it will put pressure on the garbage collector, assuming >> it's not just called a few times. >> > &

[go-nuts] pprof "disasm" command not working?

2020-01-26 Thread Kevin Malachowski
This is perhaps due to some silly thing I am doing, but I at least have a minimal test case so I figured I'd reach out for help at this point: I cannot get "disasm" in "go tool pprof" working. "list" works correctly afaict (and weblist too), but "disasm" only prints out the total time, not the

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread 'Kevin Malachowski' via golang-nuts
It is not a new declaration, it is definitely an assignment. This can be determined because (in Go) a new declaration has effects when closing over variables: https://play.golang.org/p/a_IZdOWeqYf (ignore the obvious race condition; it works the same but looks uglier with the requisite locks: h

Re: [go-nuts] Re: Garbage collector and Slices

2018-08-20 Thread 'Kevin Malachowski' via golang-nuts
That information is old now - Go has a precise GC now. There is some sort of metadata stored for each variable related to whether the type contains pointers (as Jan alluded to earlier in the thread). On Monday, August 20, 2018 at 7:28:51 AM UTC-7, Florian Uekermann wrote: > > From the GC POV, th

[go-nuts] Re: [RFC] Dynamically instrumentation Go binaries

2018-11-15 Thread 'Kevin Malachowski' via golang-nuts
If you can't recompile the binary, an option is to use a generic dynamic instrumentation platform like DynamoRIO (which I think works for Go programs after a recent bugfix). It works on windows, mac, and linux, and has been used in the past for various s

Re: [go-nuts] Re: Best way to handle database transactions? (commit, or rollback on error)

2018-12-03 Thread 'Kevin Malachowski' via golang-nuts
The best way to access the return value of a function is to name the return variable: func DoTwoThings(db *Database) (err error) { tx, err := db.Begin() if err != nil { return err } defer tx.Close(&err) ... } Then any accidental shadowing doesn't matter because the "defer" is referring to the

Re: [go-nuts] scanner.Scan is holding my goroutine ;(

2018-12-13 Thread 'Kevin Malachowski' via golang-nuts
Can you post a short, self-contained (compile-able and runnable) example which shows the problem? Preferably hosted on play.golang.org for easy sharing and editing. If the scanner is reading from a reader which has been closed (returns io.EOF), the sc.Scan should return false (and the sc.Err wo

[go-nuts] runtime.readmemstats -> buckhash_sys increase

2018-12-24 Thread 'Kevin Malachowski' via golang-nuts
Is your application leaking memory allocated in C? (Are you using cgo-related packages at all?) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsub

[go-nuts] defer at struct level

2016-08-21 Thread 'Kevin Malachowski' via golang-nuts
Do you have a code sample? I don't quite understand what you mean by something being "wrapped" in a struct. Will 'a' be a field in a struct? If so, you can just access it: defer myStructValue.a.Close() -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Are receivers from a channel fifo?

2016-08-21 Thread 'Kevin Malachowski' via golang-nuts
Try it out :) seems like a simple enough test program to write. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more

[go-nuts] Duplicate File Checker Performance

2016-10-15 Thread 'Kevin Malachowski' via golang-nuts
It also might be inefficient to call Sum multiple times with smaller slices compared to calling it once with a larger slice. Try using io.CopyBuffer and passing in larger buffer sizes to see if the CPU and memory usage start to converge. -- You received this message because you are subscribed

[go-nuts] Duplicate File Checker Performance

2016-10-15 Thread 'Kevin Malachowski' via golang-nuts
Sorry, I meant that calling Write on the hash type might be slower if it's called more often. (I'm on mobile right now. When I get back to a keyboard I'll try to come up with an example) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsub

Re: [go-nuts] Is there a way to check if all pending finalizers have been executed?

2016-10-16 Thread 'Kevin Malachowski' via golang-nuts
In that case it's generally "better" to have an explicit Close on your Go type which causes the explicit freeing of C memory. This can be tedious depending on your specific code, though. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubs

Re: [go-nuts] Why were tabs chosen for indentation?

2017-03-19 Thread 'Kevin Malachowski' via golang-nuts
I love that Go uses tabs because I use 3 spaces for my tabstop, and very few people share that preference. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang

[go-nuts] use of builtin print for debug

2017-05-08 Thread 'Kevin Malachowski' via golang-nuts
You can declare a func "print" in each package which just calls the real print func. When you want to turn off printing, you just have one line to comment out in that func to affect all callers. I'm curious why fmt.Printf doesn't work for you, though. In that case you'd still probably want a wa