[go-nuts] Re: Want to know differance between two code snippets defined here

2019-06-06 Thread Sam Mortimer
I suspect it's the classic that I think everyone does at least once - in the second code block the for loop reuses the same storage on each iteration for the variable site. Try adding: site := site ..just before your append to verify this. Cheers, -Sam. On Thursday, June 6, 2019 at 6:49:00

Re: [go-nuts] Re: Want to know differance between two code snippets defined here

2019-06-06 Thread Burak Serdar
On Thu, Jun 6, 2019 at 9:28 PM Sam Mortimer wrote: > > I suspect it's the classic that I think everyone does at least once - in the > second code block the for loop reuses the same storage on each iteration for > the variable site. Try adding: > site := site > ..just before your append to

Re: [go-nuts] Re: Want to know differance between two code snippets defined here

2019-06-06 Thread Manish Champaneri
Link to complete project : https://github.com/mchampaneri/go-multihost File that contains this code https://github.com/mchampaneri/go-multihost/blob/master/proxy.go Json file containing site details https://github.com/mchampaneri/go-multihost/blob/master/server.json On Friday, June 7, 2019 at

Re: [go-nuts] In-Method declaration of array of struct literals vs global var?

2019-06-06 Thread Steven Blenkinsop
= is always required when you're assigning a value to the var. the confusion might be that you can also have a declaration like var bar []struct{a, b, c string} where you don't assign a value to bar (meaning it will be null). Really, the syntax is var variableName Type = value You can leave

Re: [go-nuts] Want to know differance between two code snippets defined here

2019-06-06 Thread Burak Serdar
On Thu, Jun 6, 2019 at 8:09 PM Manish Champaneri wrote: > > Hi Burak, > > In working code, every route get attached to mux. > > In non working code, only last route of the loop get retain while earlier > all gets vanished. Try fmt,Printf("%v",dispatchMux) for both programs and see if there's

[go-nuts] Memory allocation question

2019-06-06 Thread Mark Bauermeister
Sorry in advance for the somewhat messy code, but this is something I've been trying to understand all day and can't quite come up with an explanation for. Basically, I wrote the below code to experiment with different data types and their impact on performance and memory efficiency. The code

[go-nuts] why need "assist garbage collection" at a GC cycle? (runtime Code)

2019-06-06 Thread ding liu
I cann`t find any infomation about "assist garbage collection" with google, so what`s the purpose of "assist garbage collection"? -- 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,

Re: [go-nuts] why need "assist garbage collection" at a GC cycle? (runtime Code)

2019-06-06 Thread fgergo
Maybe the detail you are looking for is something like this: https://blog.golang.org/ismmkeynote On 6/6/19, ding liu wrote: > I cann`t find any infomation about "assist garbage collection" with google, > > so what`s the purpose of "assist garbage collection"? > > -- > You received this message

Re: [go-nuts] Memory allocation question

2019-06-06 Thread Conrado P . L . Gouvêa
The garbage collector won't necessarily run between the functions. If you add "runtime.GC()" between functions you'll see that the Array Implementation won't use the heap very much. There is still some differences, though: https://play.golang.org/p/aYZAzoCzUM4 Map Implementation Latency: 0s

[go-nuts] Re: modules: available GOPROXY instances or implementations?

2019-06-06 Thread 盛傲飞
Hi, I just created Goproxy three days ago, which is currently the most dead simple way to build a Go module proxy, I guess. BTW, the https://goproxy.cn you mentioned is based on Goproxy. Note that Goproxy will be production-ready very soon, after I have

[go-nuts] You may not need to use Athens, but instead use Goproxy

2019-06-06 Thread 盛傲飞
The Go module proxy should be a *very small thing*. At least from the protocol it should be. But the Athens seems to over-interpret this feature. I tried to read its code. To be honest, no offense, I was

[go-nuts] make an empty slice

2019-06-06 Thread sasikala tholisam
test []Exam type Exam struct{ Time uint32 LogType uint32 Data [32]byte } test is a slice of []Exam..It should be an empty slice...how to make test as empty? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

[go-nuts] Want to know differance between two code snippets defined here

2019-06-06 Thread Manish Champaneri
I am try to add routes to mux read from json using for loop In one code i am directly appending route to mux In other code I am calling a function which appends route to mux ( mux is pass by pointer) Though both are doing same thing ( As I guess ) output is different.* I am curious why this

[go-nuts] make an empty slice

2019-06-06 Thread Mark Bauermeister
You mean a slice that is not of type Exam? test []int Should work. Your slice does need to adhere to some type. -- 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

Re: [go-nuts] Memory allocation question

2019-06-06 Thread fgergo
To share code please use Share on play.golang.org. For the rest, please no screenshots, plain text is best. On 6/6/19, Mark Bauermeister wrote: > Sorry in advance for the somewhat messy code, but this is something I've > been trying to understand all day and can't quite come up with an >

[go-nuts] [48]byte should be make to empty

2019-06-06 Thread sasikala tholisam
test [48]byte make to empty.. How to do it? -- 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. To view this discussion on

Re: [go-nuts] [ANN] Gio: portable immediate mode GUI programs in Go for iOS/tvOS, Android, macOS, Linux, Windows

2019-06-06 Thread Elias Naur
On Thursday, 6 June 2019 00:43:22 UTC+2, dol...@gmail.com wrote: > > Him > > Source Hut actually requires me to create an account to read the mailing > list. Hmph. > That's surprising. I went to https://lists.sr.ht/~eliasnaur/gio-dev with a private browser session and it showed up fine. The

Re: [go-nuts] [48]byte should be make to empty

2019-06-06 Thread Michel Levieux
Hi, It is not quite clear what you are trying to do, but if I understand it well: var array = [48]byte{} should initialize your array with zero values. Le jeu. 6 juin 2019 à 15:48, sasikala tholisam a écrit : > test [48]byte make to empty.. > How to do it? > > -- > You received this message

Re: [go-nuts] Interate over an interface

2019-06-06 Thread Burak Serdar
On Thu, Jun 6, 2019 at 7:48 AM Iago Santos wrote: > > Hi, > > I have the following code: https://pastebin.com/hAbnPV3C > > What I am trying to do in the line 347 is to get the first item of an > interface map[string]map[string]string, in any case I as not able to get it. > The result of the line

Re: [go-nuts] Want to know differance between two code snippets defined here

2019-06-06 Thread Burak Serdar
On Thu, Jun 6, 2019 at 7:48 AM Manish Champaneri wrote: > > > I am try to add routes to mux read from json using for loop > > In one code i am directly appending route to mux > In other code I am calling a function which appends route to mux ( mux is > pass by pointer) > > Though both are doing

Re: [go-nuts] make an empty slice

2019-06-06 Thread Marvin Renich
* sasikala tholisam [190606 09:49]: > > test []Exam > > type Exam struct{ > Time uint32 > LogType uint32 > Data [32]byte > } > > test is a slice of []Exam..It should be an empty slice...how to make test > as empty? After changing the first line to var test []Exam your code will

Re: [go-nuts] In-Method declaration of array of struct literals vs global var?

2019-06-06 Thread Ian Lance Taylor
On Thu, Jun 6, 2019 at 10:56 AM ajs via golang-nuts wrote: > > I can declare literal bar inside a function like this: > > func foo() { > bar := []struct{a, b, c string} { > { "really", "long", "row"}, > { "many", "many", "rows"}, > ... > } > } > > But I really want it anchored

[go-nuts] In-Method declaration of array of struct literals vs global var?

2019-06-06 Thread ajs via golang-nuts
I can declare literal bar inside a function like this: func foo() { bar := []struct{a, b, c string} { { "really", "long", "row"}, { "many", "many", "rows"}, ... } } But I really want it anchored (for code generation reason) outside of a function like this: func foo() { ... }

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-06 Thread Burak Serdar
On Wed, Jun 5, 2019 at 10:31 PM Randall O'Reilly wrote: > > On Jun 5, 2019, at 8:36 PM, Burak Serdar wrote: > > > > On Wed, Jun 5, 2019 at 11:47 AM Randall O'Reilly > > wrote: > >> > >> It’s great to see that so many people share my considerable enthusiasm for > >> this proposal! Seriously,

Re: [go-nuts] Re: A good indicator of code quality

2019-06-06 Thread andrey mirtchovski
"does it look like the go standard library?" that style is desirable, yet inimitable -- 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

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-06 Thread Michal Strba
I really can’t promise to ever fully evaluate all generics proposals. Perfectly understandable. I’ll show the benefits without you needing to fully evaluate the proposal then :) it’s still unusual in Go for a name that appears in a list to become in scope for the rest of the list and for the

[go-nuts] Re: Go 2 generics counterproposal: giving up restricting types

2019-06-06 Thread Carl
This proposal makes sense to me. Disclaimer: I don't know enough about language design to provide feedback on how it may be refined. This is just my perspective as a potential future user. 1. It is one of the simplest proposals I've read so far (but I have not read them all - there are

[go-nuts] global var available in different files (same package)

2019-06-06 Thread Natxo Asenjo
hi, I'd like to define a couple of global variables in a small cli app. The app has a few files but it's not large. What I'd like is to use cli flags to define options, and those options should be available for all the functions. I quite like the fact that the content of the variables is

[go-nuts] A good indicator of code quality

2019-06-06 Thread Carl
I'd like to know what people are using to measure the quality of their Go code bases and why. Specifically, I'm asking if: 1. There is a way to score a code base on quality that works with idiomatic Go 2. Use this metric in a CI system and fail the build if the quality falls 3. Use

Re: [go-nuts] In-Method declaration of array of struct literals vs global var?

2019-06-06 Thread 'Aaron Spangler' via golang-nuts
Thank you! You are correct. That was exactly my problem. Adding the equals sign (=) solved it. I guess I need to be more aware that sometimes an equals statement is required on a 'var' line and other times it is not. (perhaps only when it has a literal) Thanks again! On Thu, Jun 6, 2019 at

[go-nuts] Re: A good indicator of code quality

2019-06-06 Thread Robert Johnstone
You can look at https://goreportcard.com/ to get a look at some common metrics. There are also quite a few different linters (golint, revive, staticcheck, plus others). Robert On Thursday, 6 June 2019 15:58:19 UTC-4, Carl wrote: > > I'd like to know what people are using to measure the