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

2017-08-21 Thread Alexandru Bonini
Thanks Dave, works fine :) On Monday, August 21, 2017 at 5:25:11 PM UTC+9, Dave Cheney wrote: > > Reopen the file after vim exists, it will be replacing the file by > renaming the vin .swp file, not overwriting its contents. -- You received this message because you are subscribed to the Google

Re: [go-nuts] Re: Gathering Ideas for Go 2.

2017-08-21 Thread Henrik Johansson
I am sorry Dave but you can ignore the needs of the many few as much as you want but the tiny things won't go away. There probably won't be any _written_ experience reports for most of the little things. The things that people live through and sometimes just have the time to email the list about a

Re: [go-nuts] Seemingly peculiar behavior with nil checks on pointers to structs encapsulating interfaces.

2017-08-21 Thread Dan Kortschak
This is explained here https://golang.org/doc/faq#nil_error On Mon, 2017-08-21 at 09:41 -0700, ellief...@gmail.com wrote: > Hi, > > I just bumped heads with an odd behavior that I can't quite wrap my > head  > around involving nil pointers to structs that encapsulate interfaces. > > The setup is

[go-nuts] Re: Domain-driven design and go

2017-08-21 Thread helloPiers
This topic reminded me of this other thing I remember seeing: https://github.com/marcusolsson/goddd - there are some further links to blog posts and stuff on the README on that project, and there's a related talk on YouTube from one of the Go conferences. On Friday, August 18, 2017 at 11:29:0

[go-nuts] Seemingly peculiar behavior with nil checks on pointers to structs encapsulating interfaces.

2017-08-21 Thread elliefops
Hi, I just bumped heads with an odd behavior that I can't quite wrap my head around involving nil pointers to structs that encapsulate interfaces. The setup is a little convoluted, but I demonstrated it on the go playground here: https://play.golang.org/p/2WKFjLOKzn Basically, if you encapsula

[go-nuts] Best way to truncate a ridiculously long string in GO

2017-08-21 Thread Tamás Gulácsi
prefix := string([]byte(verylongstring[:3])) -- 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 htt

[go-nuts] Re: Best way to truncate a ridiculously long string in GO

2017-08-21 Thread djadala
https://play.golang.org/p/YXXlJlsNGa Hi, i'm not sure if compiler is smart enough to optimize v1, but likely v2 ends in separate memory. On Tuesday, August 22, 2017 at 3:04:42 AM UTC+3, Travis Keep wrote: > > Suppose you have code like this > > > // verylongstring may be several thousand b

[go-nuts] Best way to truncate a ridiculously long string in GO

2017-08-21 Thread Travis Keep
Suppose you have code like this // verylongstring may be several thousand bytes long verylongstring := GetSomeVeryLongString() prefix := verylongstring[:3] prefixStore.StorePrefixForDurationOfApplication(prefix) If I understand correctly, verylongstring cannot be garbage colle

[go-nuts] Re: Gathering Ideas for Go 2.

2017-08-21 Thread Dave Cheney
I'd like to echo Egon's point. We were both in the audience for Russ's announcement (although the video and the text are faithful reproductions) and Russ clearly asked for examples where "Go fails to scale" as starting points for a future version of Go. Starting from "this is a neat feature fro

[go-nuts] Re: DialTLS + Context with http Transport

2017-08-21 Thread Gabriel Rosenhouse
Thanks for the suggestion. Unfortunately VerifyPeerCertificate does not receive the request's Context, so it is not possible to have its behavior depend on per-request data. As a follow-up, we've opened https://github.com/golang/go/issues/21526 Regards, Gabe On Friday, August 18, 2017 at 9:3

Re: [go-nuts] Testing that an implementation satisfies an interface in the standard library

2017-08-21 Thread 'Axel Wagner' via golang-nuts
I think in general that will be very hard to do, generically. The reason is, that the precise edge cases in which the behavior is critical depend so much on your implementation. The best I can think of would be to write a wrapper which checks the invariants given and run your implementation-specif

Re: [go-nuts] Re: Gathering Ideas for Go 2.

2017-08-21 Thread 'Axel Wagner' via golang-nuts
On Mon, Aug 21, 2017 at 9:01 PM, Henrik Johansson wrote: > There are most likely other things that are of similar status. The > context/value/bag thing seems like such thing to be more concrete. With a > stronger type system it could be much less obscure (not too much on my feet > here I admit).

[go-nuts] Testing that an implementation satisfies an interface in the standard library

2017-08-21 Thread Carl
Satisfying a standard interface like io.Reader or io.Writer correctly is not just a matter matching the function signatures, but rather adhering to behaviour that is documented in comments Is there a standard way for me to specify an implementation of such an

Re: [go-nuts] Error: opcode not supported on this processor: mips32

2017-08-21 Thread Sander van Harmelen
To answer this question (after talking on Gopher Slack about this one)… As the target is a 32bit architecture, that max size is max_uint32/4 Sander On 21/08/2017, at 11:32 , Sander van Harmelen wrote: I’ve made some nice progression and am able to generate all kinds of binaries for my mips

Re: [go-nuts] Re: Gathering Ideas for Go 2.

2017-08-21 Thread Egon
On Monday, 21 August 2017 22:02:36 UTC+3, Henrik Johansson wrote: > > Experience reports are very valuable but there are many things that are > hardly possible to formulate as "something that hurt and needs to be fixed". > For example the dreaded generics, it doesn't hurt much but I think that,

Re: [go-nuts] Gathering Ideas for Go 2.

2017-08-21 Thread Jan Mercl
You're right. A particular (innovation) step is sometimes like evolution blindly trying options, but (only) on the long run the improvements are clearly there. On Mon, Aug 21, 2017, 20:47 Henrik Johansson wrote: > No but generally I would say that _everything_ is better today than lets > say fif

Re: [go-nuts] Re: Gathering Ideas for Go 2.

2017-08-21 Thread Henrik Johansson
Experience reports are very valuable but there are many things that are hardly possible to formulate as "something that hurt and needs to be fixed". For example the dreaded generics, it doesn't hurt much but I think that, for me, it is more that I am so happy with Go in general that I sort of forge

Re: [go-nuts] Gathering Ideas for Go 2.

2017-08-21 Thread Henrik Johansson
No but generally I would say that _everything_ is better today than lets say fifty years ago. Maybe every step wasn't better than the one immediately before but many steps later it surely is. If there was a way to easily test language features as just pulling in the golango.org/x libs then this co

[go-nuts] Re: Gathering Ideas for Go 2.

2017-08-21 Thread Egon
I must add these here: 1. https://www.youtube.com/watch?v=0Zbh_vmAKvk 2. https://www.youtube.com/watch?v=wpHggcP-L5M 3. https://blog.golang.org/toward-go2 Core team is asking for "Experience Reports"... which are not the same as "Feature Proposals". Many of the proposals I've noticed come witho

Re: [go-nuts] Gathering Ideas for Go 2.

2017-08-21 Thread Jan Mercl
On Mon, Aug 21, 2017, 19:32 Michael Jones wrote: > I don't think it's about language. I got downvotes immediately for my > comments over the weekend. > https://github.com/golang/go/issues/19623 > > Whatever the circumstances, any proposal will often have its detractors as > the most immediate and

Re: [go-nuts] Gathering Ideas for Go 2.

2017-08-21 Thread Michael Jones
I don't think it's about language. I got downvotes immediately for my comments over the weekend. https://github.com/golang/go/issues/19623 Whatever the circumstances, any proposal will often have its detractors as the most immediate and vocal responders. Support may come later. Agree that openmin

[go-nuts] Gathering Ideas for Go 2.

2017-08-21 Thread ojucie
If you guys allow me, I have a little concern about the Go 2 process. I perceived some harsh debates when someone propose a new idea. That is not the proper attitude. Please consider that the core team explicitly asked for new ideas. As a comunity we are used to deny the value of some novel propo

[go-nuts] Re: License for x/image/testdata and x/image/font/testdata files

2017-08-21 Thread athoscribeiro
Hello Ian and Nigel, There were doubts on how to distribute those files in Fedora, which now are cleared. Thanks for your reply! -- 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] Go 2 suggestion - Types like "int?"

2017-08-21 Thread Henry
I am not sure I follow your arguments here. ADTs are stuffs like Customer, Address, Invoice, etc. and I don't think they should be bolted into the language. They are abstract types you make your own so that you can describe your data in terms of the problem you are trying to solve. They are ess

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

2017-08-21 Thread Konstantin Khomoutov
On Mon, Aug 21, 2017 at 12:56:19PM +, Jan Mercl wrote: >> That is >> >> const onethird = 1 / 3 >> >> has greater precision than >> >> onethird := float64(1) / 3 > > Zero does not seem to have greater precision than 0. when > approximating the real number 1/3. IMHO, the less s

[go-nuts] Re: Converting type map[string]interface {} to type map[interface {}]interface {}

2017-08-21 Thread Volker Dobler
On Monday, 21 August 2017 16:48:07 UTC+2, Tong Sun wrote: > > How to converting type map[string]interface {} to type map[interface > {}]interface {}? > You cannot: https://golang.org/doc/faq#convert_slice_of_interface but I don't know how to fix it. > You need an explicit loop just like in ht

Re: [go-nuts] Converting type map[string]interface {} to type map[interface {}]interface {}

2017-08-21 Thread Josh Humphries
You can't convert between maps with different types of keys or values. So you have to copy the map into one with the correct target type: https://play.golang.org/p/qmD2pypNbj *Josh Humphries* jh...@bluegosling.com On Mon, Aug 21, 2017 at 10:48 AM, Tong Sun wrote: > Hi, > > How to converti

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

2017-08-21 Thread Tong Sun
On Monday, August 21, 2017 at 10:27:11 AM UTC-4, Henrik Johansson wrote: I don't like needless boxing but I am not too keen on hiding it in the > type system either. > Without a standard way, you will sure see different people doing different things, and don't agree with each other. I'm no

[go-nuts] Re: Is this bad concurrency?

2017-08-21 Thread bill . warner
That is ok, though, because the goroutine is exiting anyway. But I take your point, it's still a race condition -- two atomic operations in a row aren't helping. It's the same situation as testing (but not acquiring) a mutex before entering a function. On Friday, August 18, 2017 at 9:59:51 PM U

[go-nuts] Converting type map[string]interface {} to type map[interface {}]interface {}

2017-08-21 Thread Tong Sun
Hi, How to converting type map[string]interface {} to type map[interface {}]interface {}? I got cannot convert m (type map[string]interface {}) to type map[interface {}]interface {} but I don't know how to fix it. https://play.golang.org/p/VU4ND_6JU_ please help. Thx. -- You recei

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

2017-08-21 Thread Henrik Johansson
I guess anywhere where absent and the default value introduces some ambiguity. But as Josh so nicely describes the gRPC case the solution is boxing. I don't mind I think. I don't like needless boxing but I am not too keen on hiding it in the type system either. mån 21 aug. 2017 kl 15:51 skrev Ch

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

2017-08-21 Thread Chris Hopkins
I'm struggling to understand, >From what I grasp this is a request for syntactic sugar to save typing: type intOptional *int and various new(intOptional) calls? or is it purely about the interface to a json/xml/protobuf struct that may have optional fields present? If the second then surely it'

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

2017-08-21 Thread Josh Humphries
On Mon, Aug 21, 2017 at 9:38 AM, Henrik Johansson wrote: > I understand the the issue you are having. We had the same where we > differentiate between absent string and empty string. > It was messy with data from json but it worked. > > I think "int?", Optional or Maybe are not as helpful in Go a

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

2017-08-21 Thread Henrik Johansson
I understand the the issue you are having. We had the same where we differentiate between absent string and empty string. It was messy with data from json but it worked. I think "int?", Optional or Maybe are not as helpful in Go as they can be in Java or perhaps C# since a small type with custom m

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

2017-08-21 Thread Tong Sun
On Monday, August 21, 2017 at 3:44:41 AM UTC-4, Henry wrote: In my opinion, if you need a nullable type, you're entering a domain > problem. You are better off creating your own ADT (abstract data type) with > more descriptive names rather than "int?" or "float?". When we are talking about A

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

2017-08-21 Thread Jan Mercl
On Mon, Aug 21, 2017 at 1:46 PM Konstantin Khomoutov wrote: > That is > > const onethird = 1 / 3 > > has greater precision than > > onethird := float64(1) / 3 Zero does not seem to have greater precision than 0. when approximating the real number 1/3. -- -j -- You received t

[go-nuts] Re: runtime: Setting GOMAXPROCS in over-scheduled Contanier Environments

2017-08-21 Thread emba . rox
Hi Josh, Did you elaborate further on this topic? Especially with the rise of multi-schedulers and mixed workloads in Kubernetes (Kubelet) I´m looking for advice and best practices how to handle these things w/out negatively affecting the go runtimes of each container. The JVM has gotten some i

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

2017-08-21 Thread Konstantin Khomoutov
On Sun, Aug 20, 2017 at 10:23:27PM -0700, chou wrote: > 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? One of the reasons for this is that constants in Go have properties which set them

Re: [go-nuts] The memory release about Turning C arrays into Go slices

2017-08-21 Thread jianzhangbjz
Sorry for late reply, thanks very much! I will have a try. 在 2017年8月18日星期五 UTC+8下午4:23:07,Konstantin Khomoutov写道: > > On Fri, Aug 18, 2017 at 10:39:29AM +0300, Konstantin Khomoutov wrote: > > [...] > > There can't be easy answer to a question like this in C. > > Consider: > > > > // This fu

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

2017-08-21 Thread Jérôme LAFORGE
> May I ask why it would be interesting to take the address of a constant? I have been already faced to this case. I usually use go swagger to generate the model from swagger spec. Go swagger generates some structure with field pointer (for example for string) where I always put the same value.

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

2017-08-21 Thread chou
Thanks for your explaination, I was just curious about the language constraint details. 在 2017年8月21日星期一 UTC+8下午2:16:25,Axel Wagner写道: > > 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 wou

Re: [go-nuts] Error: opcode not supported on this processor: mips32

2017-08-21 Thread Sander van Harmelen
I’ve made some nice progression and am able to generate all kinds of binaries for my mips system now. But I just got a new challenge… When trying to cross compile something that uses pocketsphinx I get this output: GOOS=linux GOARCH=mipsle CGO_ENABLED=1 CC=OpenWrt-Toolchain-ramips-mt7688_gcc-4.

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

2017-08-21 Thread Dave Cheney
Reopen the file after vim exists, it will be replacing the file by renaming the vin .swp file, not overwriting its contents. -- 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] Go 2 suggestion - Types like "int?"

2017-08-21 Thread roger peppe
In general, I think that *T isn't a bad way to represent "maybe there's a T here". The down sides of this representation are creation (no easy to make a pointer to an int value inline without a helper function), aliasing (if you copy the container, you haven't copied the T value too) and cache unfr

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

2017-08-21 Thread Jakob Borg
I'm not really sure what you're trying to do - the example appears to start vim on a file and then wait for it to exit, with nothing else happening. Are you interacting with vim manually in the meantime? Regardless, I bet the issue is that vim does not save the data to the same file - it saves

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

2017-08-21 Thread Henry
In my opinion, if you need a nullable type, you're entering a domain problem. You are better off creating your own ADT (abstract data type) with more descriptive names rather than "int?" or "float?". -- You received this message because you are subscribed to the Google Groups "golang-nuts" gro

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

2017-08-21 Thread Tim Heckman
Hey there, I saw your message / responded to it in the gophers Slack channel but I thought I'd reply here too. I think one thing we should clarify for the mailing list is that this _seems_ to impact Darwin (OS X) and not Linux, based on testing done by users in Slack. I was also able to replica

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

2017-08-21 Thread Konstantin Khomoutov
On Sun, Aug 20, 2017 at 08:20:08AM -0700, 823545...@qq.com wrote: > 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 concurren