Re: [go-nuts] finding a way to convert "map[string]map[string]Somthing" into "map[string]interface{}"

2019-03-02 Thread 김용빈
yes I can do this in a for loop. but that is not I want. what I really want to do is "create a function that returns sorted []string keys from any map[string]... in type safe way". when I said 'there is no easy way...' , I mean I cannot create that function easily. I did not very clarify.

[go-nuts] finding a way to convert "map[string]map[string]Somthing" into "map[string]interface{}"

2019-03-02 Thread 김용빈
I wanted sorted key of a map, of course I can do this. // myMap => map[string]map[string]Something keys := make([]string, 0) for k := range myMap { keys = append(keys, k) } but what I want is make this a function. func sortedKeys(m map[string]interface{}) { keys := make([]string, 0)

Re: [go-nuts] Is Go a single pass compiler?

2019-03-02 Thread Jesper Louis Andersen
On Thu, Feb 28, 2019 at 12:46 AM wrote: > Thanks, Ian. > > I remember reading in some compiler book that languages should be designed > for a single pass to reduce compilation speed. > > As a guess: this was true in the past, but in a modern setting it fails to hold. Andy Keep's phd

Re: [go-nuts] Is Go a single pass compiler?

2019-03-02 Thread Louki Sumirniy
It makes sense to me - since very often many of the parts that are processed are stand-alone and compile correctly (almost) by themselves (maybe a package clause to be complete in a source). These smaller pieces have to have one pass to grab their trees and symbols, and joined to the other

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-02 Thread Louki Sumirniy
The stack requirements are quite important, I think you have to either take care of freeing by adding assembler function that does that, or if you can instead allocate the buffers from Go variable declarations the GC will take care of it, if it is possible to do this (very likely I think yes,

Re: [go-nuts] finding a way to convert "map[string]map[string]Somthing" into "map[string]interface{}"

2019-03-02 Thread jake6502
There have been multiple long discussions about converting []foo to []interface{} in this group. It is not possible. Most of the discussions apply just as well to your case. If you really need a "generic" function that does this, and can't convert as suggested by Louki, then you could use

Re: [go-nuts] finding a way to convert "map[string]map[string]Somthing" into "map[string]interface{}"

2019-03-02 Thread Louki Sumirniy
It sounds like you are more asking a question about an inbuilt construct for performing this conversion, not 'can this be done'. Some are talking about the use of reflection, but I aver from this and absolutely avoid reflection at all whenever possible, with the exception of its back-end use

[go-nuts] Re: Will a pointer point to C.xxx be garbage collected by Go runtime?

2019-03-02 Thread Louki Sumirniy
It won't flag any error whatsoever, actually, but if you don't free that allocation correctly it will not be freed until termination. On Friday, 1 March 2019 06:36:50 UTC+1, Cholerae Hu wrote: > > Consider the following code: > ``` > package main > > /* > struct B { > int i; > }; > > struct A

[go-nuts] 1.12 coverage generation broken?

2019-03-02 Thread Liam
Doing the following yields no ./app.cov. Have I got it wrong, or should I file an issue? $ go test -c -covermode=count -coverpkg ./... $ ./app.test -apptest localhost:443 -test.coverprofile app.cov code coverage for v0.0.0 (unreleased) ... PASS coverage: 71.7% of statements in ./... $ ls

Re: [go-nuts] Is Go a single pass compiler?

2019-03-02 Thread Bakul Shah
Algol 68 allowed use before definition which would force more than one pass but I believe many Algol 68 compilers didn’t allow this and forced forward declarations much like in C. I suspect “multiple pass” makes less sense for modern compilers. When you can keep an entire program in memory, using

[go-nuts] Should IP.DefaultMask() exist in today's Internet?

2019-03-02 Thread John Dreystadt
I am new to Go so feel free to point out if I am breaking protocol but I ran into the function DefaultMask() in the net package and did some research. This function returns the IPMask by assuming that you are using IP class A, B, and C addresses. But this concept is from the early days of the

[go-nuts] How to properly release a new project as a V2 module

2019-03-02 Thread 'Bryan Mills' via golang-nuts
The /v2 suffix is not just for within your code: that's how you need to address the module (and import its packages) everywhere. The contents of your go.mod file suggest that your calling code, or perhaps the `go get` command you used to add the module, is missing that suffix. -- You received

[go-nuts] Re: Should IP.DefaultMask() exist in today's Internet?

2019-03-02 Thread Louki Sumirniy
The function is really just looking up the IP prefixes of the non-routeable address ranges. It has nothing to do with CIDR, it is for generating a sane default mask when the user has not specified the mask. It most definitely should not be deprecated, as these nonrouteable addresses are