Re: [go-nuts] Why constant is not addressable in golang?

2017-08-20 Thread 'Axel Wagner' via golang-nuts
If a constant was addressable, you could do const x = 42 x = 23 fmt.Println(x) // 23 so a constant wouldn't be constant anymore. The minimum Go would need, to make constants addressable would be some notion of const-pointers (that is, pointers which don't allow modification of the pointee). May

[go-nuts] Why constant is not addressable in golang?

2017-08-20 Thread chou
I guess that const will be substitute literally at compile time for performance improvements. So there is not such variable in run time. Is it right? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receivi

Re: [go-nuts] From struct to map

2017-08-20 Thread Jakob Borg
This package: https://github.com/fatih/structs Or, more generally, reflection or code generation. For your specific struct I'd just add a method to return the map representation if that's what you need. //jb On 21 Aug 2017, at 06:42, Tong Sun mailto:suntong...@gmail.com>> wrote: To covert

[go-nuts] Any idea why b.String() does not reflect the changes done in vim?

2017-08-20 Thread Alexandru Bonini
https://play.golang.org/p/_rudr2_Vyc I don't understand why any change done via vim is not reflected by b.String(). I can see the changes in the tempfile. Any help is appreciated. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe f

[go-nuts] [ANN] Zeus IDE - Version 3.97k Released

2017-08-20 Thread JussiJ
Zeus is a language neutral programmer's editor/IDE which includes support for the Go language. Go related changes new to this release include: - Updated Go tools like goimports, gocode, gorename etc - Updated Go delve debugger - New feature allowing user input for tools - More improv

[go-nuts] From struct to map

2017-08-20 Thread Tong Sun
To covert a Go struct, say, type Person struct { First string Last string } into a map, him["First"]=... him["Last"]=... One way to do it is to marshall it into json then unmarhall it back. Is this the easiest way to do it? Is there any easier ways? Thanks -- You received this messa

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Ian Lance Taylor
I'd like to ask that everybody please stay polite on this thread. Thanks. I agree that as a language proposal this requires more description. To me the use case is not clear. I think I understand the basic idea, but I do not understand the specific problems that it solves. For example, it would

Re: [go-nuts] escaping unix filename for bash invocation

2017-08-20 Thread Tong Sun
Thanks Paul, that's exactly what I really need to do. On Tuesday, December 8, 2015 at 8:51:26 PM UTC-5, Paul Borman wrote: > > It really depends on what you are trying to do with the file name, as > indicated by other posters. If you really are creating a command line that > is to be directly

[go-nuts] Re: call of reflect.Value.Int on ptr

2017-08-20 Thread qiaogongxun01
yes,all code were compiled with the same version.In my test , it can't be happend anyway with same code.Reply is *int and do nothing in function RPC1,it's very simple... 在 2017年8月21日星期一 UTC+8上午1:15:06,Tamás Gulácsi写道: > > Are both versions compiled with the exact same version ofGo? -- You rece

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Tong Sun
Thanks! In my view, whenever you are dealing with data, this (null situation) is inevitable, which makes it so useful and so fundamental that it should be considered as part of the future Go. Otherwise, you will see different people doing different things, just like different people using differen

[go-nuts] call of reflect.Value.Int on ptr

2017-08-20 Thread Tamás Gulácsi
Are both versions compiled with the exact same version ofGo? -- 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 op

Re: [go-nuts] Go channels overused and hyped?

2017-08-20 Thread Matt Harden
Mutexes are good for a some low level tasks, and when you must have a shared data structure with no clear owner. When in doubt, and when designing your app, prefer communication over sharing, i.e. channels. On Fri, Aug 18, 2017, 16:03 John Souvestre wrote: > Interesting. So you think it is a ge

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Tamás Gulácsi
Tgis is what sql.NullInt64 does, or github.com/guregu/null . -- 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 op

Re: [go-nuts] []T(nil) vs []T {}

2017-08-20 Thread Matt Harden
The first one is a type conversion, not the second. On Thu, Aug 17, 2017, 14:59 Soumya Mukherjee wrote: > Thank you both. I did not realize the latter syntax is that of a type > conversion. > > On Thursday, August 17, 2017 at 1:43:45 PM UTC-4, Axel Wagner wrote: >> >> >> >> On Thu, Aug 17, 2017

[go-nuts] call of reflect.Value.Int on ptr

2017-08-20 Thread qiaogongxun01
On centos 6.5 , go version 1.8, stack: panic: reflect: call of reflect.Value.Int on ptr Value [recovered] panic: reflect: call of reflect.Value.Int on ptr Value goroutine 52598456 [running]: encoding/gob.catchError(0xc4209e10d0) /root/go/src/encoding/gob/error.go:38 +0x95 panic(0xc40860, 0xc42606a

[go-nuts] WaitGroup should be introduced before "Exercise: Web Crawler" in "A Tour of GO"

2017-08-20 Thread 823545341
I'm a freshman. I went through the Tour of GO smoothly today, until I encountered "Exercise: Web Crawler". The exercise is at here https://tour.golang.org/concurrency/10 . This exercise requires me to implement a concurrent crawler. I write a main function like this: > func main() { > go

Re: [go-nuts] Re: golang continuous deployment & gitlab

2017-08-20 Thread Sankar P
Thanks a lot. This is good :) 2017-08-20 14:09 GMT+05:30 Diego Medina : > Hi, > > At work we have all of our deployment logic written in ansible and simply > call an ansible playbook from jenkins (gitlab-ci in your case) > > Here is a sample project using ansible > > https://github.com/fmpwizard/

[go-nuts] Re: when to switch a goroutine to be executed

2017-08-20 Thread Yp Xie
Pierre Durand, Thanks for your concise and accurate answer. 在 2017年8月20日星期日 UTC+8下午6:22:47,Pierre Durand写道: > > Goroutine execution is not deterministic. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread 'Axel Wagner' via golang-nuts
On Sun, Aug 20, 2017 at 4:34 PM, Tong Sun wrote: > > You seem to refuse to answer even the simplest questions about your > proposal, like "what's the difference to using pointers?". > > The answer lies exactly in your reply -- see how inconvenient it is > currently, just to deal with a single var

[go-nuts] Re: when to switch a goroutine to be executed

2017-08-20 Thread Yp Xie
Peter, Got your point, thanks! 在 2017年8月20日星期日 UTC+8下午10:09:50,peterGo写道: > > Yp Xie, > > The Go scheduler is cooperative: > https://en.wikipedia.org/wiki/Cooperative_multitasking > > You are using one processor: runtime.GOMAXPROCS(1). Force the main > goroutine to yield: runtime.Gosched(). >

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Tong Sun
> You seem to refuse to answer even the simplest questions about your proposal, like "what's the difference to using pointers?". The answer lies exactly in your reply -- see how inconvenient it is currently, just to deal with a single variable, whereas, what I'm dealing with is, Think of dealing

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread 'Axel Wagner' via golang-nuts
On Sun, Aug 20, 2017 at 4:08 PM, Tong Sun wrote: > The > > fmt.Println(unmarshal(`{"foo": 3}`)) > > prints a pointer instead of 3. > Yes, it is a pointer to an integer holding the value 3. If you want it to format differently, implement fmt.Stringer. > > This is NOT what I'm asking for, despit

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Tong Sun
On Sun, Aug 20, 2017 at 10:06 AM, Wojciech S. Czarnecki wrote: Ah, so Go core team should puff, bow then break Go type system asap. > Just because some sloppy coder in outer world may produce invalid data > and present coder is too lazy to write proper validation for that? > This is in correct.

[go-nuts] Re: when to switch a goroutine to be executed

2017-08-20 Thread peterGo
Yp Xie, The Go scheduler is cooperative: https://en.wikipedia.org/wiki/Cooperative_multitasking You are using one processor: runtime.GOMAXPROCS(1). Force the main goroutine to yield: runtime.Gosched(). For example, https://play.golang.org/p/7HnogkMOOo 0: main 1: main 0: not main 2: main 1: n

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Tong Sun
The fmt.Println(unmarshal(`{"foo": 3}`)) prints a pointer instead of 3. This is NOT what I'm asking for, despite what you think. I think any further explanation is pointless, since you disagree from the very first. It'll be fruitless trying to make you look from other's view. All I'm trying to

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Wojciech S. Czarnecki
On Sat, 19 Aug 2017 08:05:34 -0700 (PDT) Tong Sun wrote: > Suggesting C# type syntax like "int*?*" so as to take nil as valid value. Should 'int' type also support a 'NaN' then? Nil (NULL) is *not* a number. Thats why it has its own keyword, one almost universally associated with pointers only

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread 'Axel Wagner' via golang-nuts
On Sun, Aug 20, 2017 at 3:21 PM, Tong Sun wrote: > On Sun, Aug 20, 2017 at 2:22 AM, Axel Wagner < > axel.wagner...@googlemail.com> wrote: > > ii := new(int) >> (*ii) = 3 >> (*ii)++ >> >> Yes, it's not exactly the same syntax. It still demonstrates that what >> you are suggesting creates, at best,

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-20 Thread Tong Sun
On Sun, Aug 20, 2017 at 2:22 AM, Axel Wagner wrote: ii := new(int) > (*ii) = 3 > (*ii)++ > > Yes, it's not exactly the same syntax. It still demonstrates that what you > are suggesting creates, at best, very marginal benefit. > This is where I don't agree on. var ii *int > This is what you are

[go-nuts] [blog] Generic Adapters + a question about reflection

2017-08-20 Thread Mike Houston
I don't know if anyone cares about another attempt to brute-force generics into Go 1, but I've written up a proof of concept here: http://kothar.net/generic-adapters This uses structs with func fields to emulate methods, and then generates adapters at runtime between the typed functions and the

[go-nuts] MPFR (big number math)

2017-08-20 Thread me
Are there any bindings to MPFR (similar to Gnu MP library) Searched and could not find much on google or github. MPFR has more functions than GMP which are handy. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group an

[go-nuts] Re: when to switch a goroutine to be executed

2017-08-20 Thread Pierre Durand
Goroutine execution is not deterministic. -- 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:

[go-nuts] Re: when to switch a goroutine to be executed

2017-08-20 Thread Yp Xie
PS: https://play.golang.org/p/ax_bsnEJ1Q I added more goroutine to see what the result would be: package main import ( "runtime" "fmt" "sync" ) func main() { runtime.GOMAXPROCS(1) wg := sync.WaitGroup{} for i := 0; i < 5; i++ { wg.Add(1) fmt.Printf("%d: main\n", i) go func (i int) { fmt.Printf

[go-nuts] Re: golang continuous deployment & gitlab

2017-08-20 Thread Diego Medina
Hi, At work we have all of our deployment logic written in ansible and simply call an ansible playbook from jenkins (gitlab-ci in your case) Here is a sample project using ansible https://github.com/fmpwizard/mrwilson/tree/master/ansible it has all the roles, code, etc needed to start with a

[go-nuts] Re: recent golang toolchain build issue

2017-08-20 Thread peterGo
Peter, Yes, It's really, really annoying. See https://github.com/golang/go/issues/21452. Temporarily, I'm running $ rm -f ../pkg/linux_amd64_shared/runtime/cgo.a && ./all.bash Peter On Sunday, August 20, 2017 at 12:57:43 AM UTC-4, Peter Arnt wrote: > > Greetings, > > I have been tracking the