[go-nuts] Why can't we do timer related works in sysmon rather than another timer goroutine?

2017-08-10 Thread Cholerae Hu
Currently if we use timer or something, runtime will start a new goroutine to do timerproc works. Why can't we check timer heap in each iteration of sysmon if any timer exists? This may reduce some context switchs, I think. -- You received this message because you are subscribed to the Google

Re: [go-nuts] Check for minimum Go version

2017-08-10 Thread Michael Banzon
Thanks for the responses. I will try a few options and see what fit best. For a bit of context I’m making a script to check if the entire toolchain needed to build a project is present on the machine. The script checks for node/npm, Go, GCC and a few other tools (like go-bindata eg.). The real

Re: [go-nuts] Returning a JSON object saved as a string in a database

2017-08-10 Thread Dmitriy Cherchenko
Wow that appears to be exactly the answer I'm looking for! Thank you. Just to make sure: When marshalling a struct, will fields of type json.RawMessage be ignored (simply inserted into the JSON object without further processing)? On Thursday, August 10, 2017 at 7:27:17 PM UTC-7, Jakob Borg

[go-nuts] Re: Calling Once (in the code)

2017-08-10 Thread Henry
I don't fully understand the problem, but if you need a quick and dirty way to ensure a function is called exactly once, you can always use a global variable, have the function checks the variable when the function is called. If the function is called the first time, it will set the variable.

Re: [go-nuts] Returning a JSON object saved as a string in a database

2017-08-10 Thread Jakob Borg
On 10 Aug 2017, at 22:11, Dmitriy Cherchenko > wrote: What is the best way to send the stringified JSON object from the database as JSON and not as a string-type value of a property in the bigger JSON object the server is responding with? Do

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-08-10 Thread Diego Medina
Hope you had a goo time on vacation. No need for custom types, specially with csv files, all you get are "string" type, but you know that some columns are actually float values, or ints or plain text. So we have several functions that "clean, format, etc" different kinds of data, and just call

Re: [go-nuts] cgo related error assigning from a ((size_T)(-1)) define

2017-08-10 Thread Dan Kortschak
Yeah, that doesn't work. Returning the value from the C.func does though. The whole system is pretty queasy-making. (Looking at the internal behaviour of SetSize, it should probably not take a uint64, since it expects a -1 sentinel for variable length). On Thu, 2017-08-10 at 12:00 +0100, roger

Re: [go-nuts] Calling Once (in the code)

2017-08-10 Thread dc0d
How can that get applied here (The Halting Problem)? We use functions everywhere and this is the same as we already do (with same level of probability for Halting Problem). What I do currently: 1 - abstracting some parts of a long function in another function. 2 - the name of that second

Re: [go-nuts] go build for mips

2017-08-10 Thread lucasw
Sorry for my confused responses before. The thing was my hardware board lacked fpu, so that's why I could not make it work a simple hello world compiled with: GOOS=linux GOARCH=mips go build hello.go because the go compiler did not emmit softfloat. For other people who are facing the same

Re: [go-nuts] Why does vet's 'rangeloop' check only check the last statement of a loop?

2017-08-10 Thread spencer
Yes, it makes sense that it would be impossible to really check at that level. What surprised me was that this does not trigger vet: for i := range slice { go f(i) _ = 1 } Yet this does trigger vet: for i := range slice { _ = 1 go f(i) } Is there something special about the

Re: [go-nuts] Why does vet's 'rangeloop' check only check the last statement of a loop?

2017-08-10 Thread Steven Blenkinsop
If you have a loop like: for i := range slice { f() } There's no way to know whether f launches a goroutine that captures the loop variable without also evaluating the body of f and potentially every function directly or indirectly called by f. If i escapes into a global variable, you also

Re: [go-nuts] Returning a JSON object saved as a string in a database

2017-08-10 Thread Dmitriy Cherchenko
But then if the JSON is sent as a string property of a bigger object, it'll have to be parsed by JavaScript on the browser side. That is undesirable. On Thursday, August 10, 2017 at 1:21:54 PM UTC-7, Shawn Milochik wrote: > > On Thu, Aug 10, 2017 at 4:20 PM, Dmitriy Cherchenko

Re: [go-nuts] Returning a JSON object saved as a string in a database

2017-08-10 Thread Shawn Milochik
On Thu, Aug 10, 2017 at 4:20 PM, Dmitriy Cherchenko wrote: > Hi Shawn, > > Thank you for your quick reply! > > I’m not having any issues retrieving data from the database. I’m only > concerned that the unmarshalling and marshalling processes seem needless > and a little

Re: [go-nuts] Returning a JSON object saved as a string in a database

2017-08-10 Thread Dmitriy Cherchenko
Hi Shawn, Thank you for your quick reply! I’m not having any issues retrieving data from the database. I’m only concerned that the unmarshalling and marshalling processes seem needless and a little risky especially on big JSON objects. On Thursday, August 10, 2017 at 1:17:02 PM UTC-7, Shawn

Re: [go-nuts] Returning a JSON object saved as a string in a database

2017-08-10 Thread Shawn Milochik
Seems like something that should "just work." Are you having a problem with this? If so, please show some code. A string is a string -- if you insert a base64-encoded value (or JSON, or YAML) into a database varchar or text field, you should get the identical string back out, character for

Re: [go-nuts] Calling Once (in the code)

2017-08-10 Thread Jan Mercl
On Thu, Aug 10, 2017 at 10:03 PM dc0d wrote: > Is there a tool/linter to check if a private package function gets called exactly once in the code? Good luck with solving the halting problem ;-) -- -j -- You received this message because you are subscribed to the

[go-nuts] Why does vet's 'rangeloop' check only check the last statement of a loop?

2017-08-10 Thread spencer
I've noticed that cmd/vet's rangeloop check, which warns you about binding to range loop variables in function literals which are launched with 'go' or 'defer', is more limited than I thought:

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-08-10 Thread Sofiane Cherchalli
Hi Medina, Sorry I was on vacations. So do you mean the way to do it is to hardcode most of functionality. No need to use custom types, interfaces. Just plain text parsing? In that case, how easy is it to evolve or refactor the code? Thanks On Wednesday, July 26, 2017 at 8:36:15 PM UTC+2,

Re: [go-nuts] How to tell SQL returns empty result

2017-08-10 Thread Richard Bucker
The original question was how to determine if the result had rows. Well it turns out that golang's sql packa wi; generate the exception"ErrNoRows" if there are no rows, therefore, it is not necessary to test the rows.Next() and consume the first row differently than the second and certainly not

Re: [go-nuts] Re: Generics are overrated.

2017-08-10 Thread David Collier-Brown
On 10/08/17 09:09 AM, roger peppe wrote: On 10 August 2017 at 13:39, David Collier-Brown wrote: On 10/08/17 02:47 AM, Henrik Johansson wrote: I beg to differ. Most Java apps I have seen over many years almost unanimously suffer from over-modeling. A former customer did

Re: [go-nuts] Re: Generics are overrated.

2017-08-10 Thread roger peppe
On 10 August 2017 at 13:39, David Collier-Brown wrote: > On 10/08/17 02:47 AM, Henrik Johansson wrote: >> >> I beg to differ. Most Java apps I have seen over many years almost >> unanimously suffer from over-modeling. > > > A former customer did a deep, thoughtful, *thorough*

Re: [go-nuts] Re: Generics are overrated.

2017-08-10 Thread David Collier-Brown
On 10/08/17 02:47 AM, Henrik Johansson wrote: I beg to differ. Most Java apps I have seen over many years almost unanimously suffer from over-modeling. A former customer did a deep, thoughtful, *thorough* model of bracket tournaments, without any attempt to abstract the salient features.

Re: [go-nuts] cgo related error assigning from a ((size_T)(-1)) define

2017-08-10 Thread roger peppe
Can't you just define f5f_VARIABLE as uint64? The only place it's used it's being converted to uint anyway (which seems slightly dubious in itself). On 10 August 2017 at 09:03, Dan Kortschak wrote: > I'm pretty sure this should never have worked, but it seemed to

[go-nuts] SOAP libraries

2017-08-10 Thread Srinath
Hi all, Are there good SOAP libraries to generate structs given WSDL? Looking for something that would generate idiomatic Go code. Thanks, Srinath G S [image: --] Srinath GS [image: https://]about.me/srinathgs

Re: [go-nuts] Offline Go Documentation Tools

2017-08-10 Thread Christoph Berger
> > Is Visual Studio Code a .Net app that takes up lots of memory and CPU? > Worse, it's an Electron app :) I use VSC on an old 2012 Mac Mini, and I cannot confirm that it consumes lots of CPU or memory, even with about two dozen extension installed. It is fast and responsive (some say it is

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread Egon
Sorry for creating confusion, my reading mistake. I read the inner-loop as: if err := bdb.Get(key, ); err == nil && val.Value() != nil { totalFound++ } else if err != nil { totalErrored++ } else { totalNotFound++ } Which it obviously is not... :/ This day doesn't seem promising after this

[go-nuts] cgo related error assigning from a ((size_T)(-1)) define

2017-08-10 Thread Dan Kortschak
I'm pretty sure this should never have worked, but it seemed to previously and now it doesn't. In the gonum/hdf5 package there is a var declared against an HDF5 define like so, `var h5t_VARIABLE int64 = C.H5T_VARIABLE`[1]. `H5T_VARIABLE` is defined in H5Tpublic.h as `#define H5T_VARIABLE

Re: [go-nuts] Check for minimum Go version

2017-08-10 Thread Konstantin Khomoutov
On Wed, Aug 09, 2017 at 03:11:48PM +0200, Michael Banzon wrote: > Is there a way to have a (bash) script check if the version of the Go > compiler installed is a specific minimum version? In the light of [1], I think you could combine checking of the presense of the `go` tool itself with build

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread peterGo
Egon, Obviously I ran the race detector. No races were detected. Therefore, since it wasn't germane, I omitted it from the posted results. Here's my results. $ go test -run=! -bench=. -v -cpu=4 -race total_test.go goos: linux goarch: amd64 BenchmarkTotal/Count-4 5000

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread Egon
Note, you also have a race in your code. Use `-race` to detect. + Egon On Thursday, 10 August 2017 06:43:34 UTC+3, d...@dgraph.io wrote: > > Hi > > I am trying to benchmark a key-value store written in Go. I have the code > as shown below. There are a few lines that are specific to the store

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread peterGo
Package testing https://golang.org/pkg/testing/ Benchmarks The benchmark function must run the target code b.N times. During benchmark execution, b.N is adjusted until the benchmark function lasts long enough to be timed reliably. The first thing to do is to reduce the program to the simplest

Re: [go-nuts] Re: Generics are overrated.

2017-08-10 Thread Henrik Johansson
I beg to differ. Most Java apps I have seen over many years almost unanimously suffer from over-modeling. That Go encourages another style of modeling does not make it too simple. It only makes it different which may be good or bad according to taste. That said, I personally think that generics