Re: [go-nuts] How to get request url scheme?

2018-11-24 Thread Anik Hasibul
Thank you so much. I thought I did something wrong. But Now I am pretty sure that it's a bug. Issue opened on GitHub! Here it is: https://github.com/golang/go/issues/28940 Hasibul Hasan (Anik) Mobile: +8801902566424 Email : anikhasi...@outlook.com Github: @AnikHasibul Medium: @AnikHasibul __

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread robert engels
You kind of made my point, when you state “it’s either a slice or a map”… Well, what if the resource needed to be ordered, which is why the previous method has List in its name, but the method was actually returning a map. Yes, someone should of caught that in the code review for the extractList

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread Ian Denhardt
Quoting robert engels (2018-11-25 00:15:21) > Contrast that with this actual code from the leading Go application (picked > at random): > > func (p *pruner) prune(namespace string, mapping *meta.RESTMapping, > includeUninitialized bool) error { > objList, err := p.dynamicClient.Resource(

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread robert engels
I whole heartily agree, and for “tight” systems-level code, with limited function APIs (like err), it works fine. The example you cite is trivial, and a “well known” API due to its common usage. Contrast that with this actual code from the leading Go application (picked at random): func (p *pr

Re: [go-nuts] How to get request url scheme?

2018-11-24 Thread Robert Engels
That should be it... file a bug > On Nov 24, 2018, at 9:21 PM, Anik Hasibul wrote: > > Hi there! > I am working on a web application. And I need to get the scheme of the > request url. > I tried `req.URL.Scheme` it returned empty string. > But my expectation was `http` or `https` > > Any idea

[go-nuts] How to get request url scheme?

2018-11-24 Thread Anik Hasibul
Hi there! I am working on a web application. And I need to get the scheme of the request url. I tried `req.URL.Scheme` it returned empty string. But my expectation was `http` or `https` Any idea to get that? -- You received this message because you are subscribed to the Google Groups "golang-n

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Ugorji Nwoke
Thanks Keith - this is what I was looking for. On Saturday, November 24, 2018 at 6:49:33 PM UTC-5, Keith Randall wrote: > > int<->uint conversions should never generate any machine code. They are > free. > > On Saturday, November 24, 2018 at 10:55:50 AM UTC-8, Andy Balholm wrote: >> >> There is n

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread Ian Denhardt
Quoting robert engels (2018-11-24 17:34:34) > Agreed, but that is why I have a big problem with variable inference as used > in Go (and now Java 9 with var). > > You need to refer to the callee API doc in order to gain understanding of the > code - as the type information is not readily available

[go-nuts] Re: go language sensitive editor?

2018-11-24 Thread Gregory Graham
Okay, while some of us are reminiscing about ed, here is my story. When I first used Unix in 1980, I learned vi, and that was my primary editor for many years. However, I learned about ed and found it to be useful in the days before windowing systems. When I would get a compile error, I sometim

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread robert engels
And as one overly anal person already pointed out - it is complement. > On Nov 24, 2018, at 6:50 PM, robert engels wrote: > > Although by the spec stating - sign extended - they are limiting Go to work > on 2’s compliment platforms… > >> On Nov 24, 2018, at 6:48 PM, robert engels >

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread robert engels
Although by the spec stating - sign extended - they are limiting Go to work on 2’s compliment platforms… > On Nov 24, 2018, at 6:48 PM, robert engels wrote: > > That is only the case if the platform uses 2’s compliment signed numbers - > which is almost certainly the case, but doesn’t have to

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread robert engels
That is only the case if the platform uses 2’s compliment signed numbers - which is almost certainly the case, but doesn’t have to be... > On Nov 24, 2018, at 6:42 PM, Dan Kortschak > wrote: > > int and uint are the same size per the spec, so there is nothing to do > (no sign extension and no

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Dan Kortschak
int and uint are the same size per the spec, so there is nothing to do (no sign extension and no subsequent truncation). What happens in other languages is largely irrelevant here (golang- nuts). On Sat, 2018-11-24 at 18:16 -0600, robert engels wrote: > This maybe true for Go, but not necessarily

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread robert engels
This maybe true for Go, but not necessarily all languages. It might be implemented as result = original & 0x7FFF (for 32 bit int to uint) it depends on how the language specifies the conversion will occur. That being said, in Go the spec says: For the conversion of non-constant numeric val

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread 'Keith Randall' via golang-nuts
int<->uint conversions should never generate any machine code. They are free. On Saturday, November 24, 2018 at 10:55:50 AM UTC-8, Andy Balholm wrote: > > There is nothing in the language spec that guarantees anything about > performance. But if logic tells you that it should be a no-op, and >

Re: [go-nuts] What's the difference between interface{} and *interface{}

2018-11-24 Thread Ian Lance Taylor
On Fri, Nov 23, 2018 at 9:12 PM, 'yinbingjun' via golang-nuts wrote: > > What's the difference between interface{} and *interface{} The first is the type of an empty interface and the second is the type of a pointer to an empty interface. What is your real question? Ian -- You received this m

Re: [go-nuts] gosnip: run small snippets of Go code from the command line

2018-11-24 Thread Justin Israel
On Sun, Nov 25, 2018, 11:06 AM Ben Hoyt wrote: > I just finished a little tool called "gosnip" that allows you to run > little snippets of Go code from the command line: > > https://github.com/benhoyt/gosnip > > To use it, just type something like: > > $ gosnip 'fmt.Println("Hello world")' >

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread Dan Kortschak
As Ian has said, this is true in some circumstances. When I want to know what something does I will read it. When I am dipping in to refresh my memory or to start investigating a bug, then I read with random access. The latter two are more common. Dan On Sat, 2018-11-24 at 16:06 -0600, robert en

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread robert engels
Agreed, but that is why I have a big problem with variable inference as used in Go (and now Java 9 with var). You need to refer to the callee API doc in order to gain understanding of the code - as the type information is not readily available. Even though there are less characters, so people c

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread Ian Denhardt
Quoting robert engels (2018-11-24 17:06:29) > I would argue that good code reads in a linear manner - if it doesn’t > it is a problem with the programmer or the language syntax/grammer. I think this is true on a small scale, but... > On Nov 24, 2018, at 3:28 PM, Dan Kortschak > wrote: > > An in

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread robert engels
To add color, even highly concurrent and parallel designers are easy to read linearly if the constructs support it. > On Nov 24, 2018, at 4:06 PM, robert engels wrote: > > I would argue that good code reads in a linear manner - if it doesn’t it is a > problem with the programmer or the languag

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread robert engels
I would argue that good code reads in a linear manner - if it doesn’t it is a problem with the programmer or the language syntax/grammer. > On Nov 24, 2018, at 3:28 PM, Dan Kortschak > wrote: > > Thanks for bumping this. I had intended to respond. > > There is a fundamental difference between

[go-nuts] gosnip: run small snippets of Go code from the command line

2018-11-24 Thread Ben Hoyt
I just finished a little tool called "gosnip" that allows you to run little snippets of Go code from the command line: https://github.com/benhoyt/gosnip To use it, just type something like: $ gosnip 'fmt.Println("Hello world")' Hello world gosnip automatically adds (standard library) im

Re: [go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread Dan Kortschak
Thanks for bumping this. I had intended to respond. There is a fundamental difference between reading English prose (or whatever your native language is) and code; prose is read as a continuous stream while code is often read in a random access manner. An interesting point here is that natural lan

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Andy Balholm
There is nothing in the language spec that guarantees anything about performance. But if logic tells you that it should be a no-op, and examination of the generated code shows you that it is a no-op in the cases you tested, you can safely assume that it is not going to be an issue for your progr

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Ugorji Nwoke
Thanks so much Silviu. I love this tool - I had seen it before, but didn't realize it also supported go language. Thanks so much for bringing it up - it should help me do more investigation on my own faster. I used it to compare the asm output, and I got the same thing as when I did go buil

[go-nuts] Re: go language sensitive editor?

2018-11-24 Thread Serge Voilokov
Thanks for pointing out. I have updated the README: https://github.com/serge-v/micro/blob/master/README.md#fork-changes On Saturday, November 24, 2018 at 10:25:41 AM UTC-5, Mandolyte wrote: > > Hmmm, couldn't we follow directions to build from zyedidia, substituting > your repo as needed? If so,

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread silviucapota
A very nice tool from Matt Godbolt (and team of volunteers): https://godbolt.org/z/4nt5cJ You can switch compiler version (e.g. Go 1.4, 1.7, 1.9, 1.11, tip, etc) and/or gccgo, take a look at variations, etc On Saturday, 24 November 2018 11:07:51 UTC-5, Jan Mercl wrote: > > On Sat, Nov 24, 2018

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Jan Mercl
On Sat, Nov 24, 2018 at 4:31 PM Ugorji Nwoke wrote: > Jan, you and I have the same understanding i.e. float <-> int is obviously non-free, but I can't think of why int <-> uint will not be free. However, I want someone with knowledge of the > compiler/runtime/codegeneration/SSA internals that ca

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Ugorji Nwoke
Jan, you and I have the same understanding i.e. float <-> int is obviously non-free, but I can't think of why int <-> uint will not be free. However, I want someone with knowledge of the compiler/runtime/codegeneration/SSA internals that can give me a definitive answer. On Saturday, November 2

[go-nuts] Re: go language sensitive editor?

2018-11-24 Thread Mandolyte
Hmmm, couldn't we follow directions to build from zyedidia, substituting your repo as needed? If so, have you documented anywhere how to use your extensions? I didn't notice any mods to the README. Cheers! On Wednesday, November 21, 2018 at 4:57:05 PM UTC-5, Serge Voilokov wrote: > > I am using

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Jan Mercl
On Sat, Nov 24, 2018 at 4:02 PM Ugorji Nwoke wrote: > I understand the rules from the context of the language and what the compiler will accept - conversion MUST be explicit. I am asking if there is any runtime cost to the conversion between int and uint, > given that they "should" have the same

Re: [go-nuts] GoAWK: an AWK interpreter written in Go

2018-11-24 Thread Tong Sun
On Sat, Nov 24, 2018 at 10:11 AM Ben Hoyt wrote: For what it's worth, I found that tool quite interesting and relevant. > Tong, I think you're overreacting a bit here. > Oh, I'm sorry, *everyone*. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group

Re: [go-nuts] GoAWK: an AWK interpreter written in Go

2018-11-24 Thread Ben Hoyt
> > probably this is better tool for the >> case >> > > - please don't just post a link, but include descriptions. > - please justify your claim "better" - a specific log file parser is > better than general-purpose awk scripts? In what way? > - please don't hija

Re: [go-nuts] GoAWK: an AWK interpreter written in Go

2018-11-24 Thread Ben Hoyt
> Hope there are future plans to extend it so that, > - people can define user function in go and use it in goawk > > handling, > as kty... has pointed out. > I toyed

Re: [go-nuts] Re: go language sensitive editor?

2018-11-24 Thread Tong Sun
On Fri, Nov 23, 2018 at 11:40 AM Serge Voilokov wrote: > > No, no plans to PR for a while since I implemented the features directly > in the source tree. > I need to think how to wrap them as plugins for dynamic download. > What you believe can benefit yourself can surely benefit the Go community

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Ugorji Nwoke
Thanks Jan. But my question was different. I understand the rules from the context of the language and what the compiler will accept - conversion MUST be explicit. I am asking if there is any runtime cost to the conversion between int and uint, given that they "should" have the same represen

Re: [go-nuts] GoAWK: an AWK interpreter written in Go

2018-11-24 Thread Tong Sun
On Sat, Nov 24, 2018 at 6:44 AM Denis Cheremisov wrote: > > - also enable normal go program to use awk scripts > > probably this is better tool for the > case > - please don't just post a link, but include descriptions. - please justify your claim "better" - a

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Jan Mercl
On Sat, Nov 24, 2018 at 3:43 PM Ugorji Nwoke wrote: Here is the authoritative answer: A non-constant value x can be converted to type T in any of these cases: - x is assignable to T. - igno

[go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Ugorji Nwoke
I have code that uses uint for element or slicing index, as it elides one half of the bounds check (i.e. no need to check if the index >= 0, as it always is). However, I tend to now convert a lot between int and uint. I would think that the conversion between both is free (a no-op at runtime)

[go-nuts] Syntax highlighting (again) [WAS go language sensitive editor?]

2018-11-24 Thread Sam Whited
On Fri, Nov 23, 2018, at 17:06, Jay Ts wrote: > Nowadays I use vim > because there are a few nice things about it that aren't in vi. At least, > vim is ok after you turn off syntax highlighting and all the other newbie > crutches. :-P Seriously, how many people can't read or write in English (or

Re: [go-nuts] GoAWK: an AWK interpreter written in Go

2018-11-24 Thread Denis Cheremisov
> - also enable normal go program to use awk scripts probably this is better tool for the case суббота, 24 ноября 2018 г., 5:43:22 UTC+3 пользователь Tong Sun написал: > > > > On Saturday, November 17, 2018 at 12:44:57 PM UTC-5, Ben Hoyt wrote: >> >> >> https