Re: [go-nuts] Re: How to print arrays with commas and brackets

2020-08-07 Thread Henry
First, there is no such requirement in the OP's original post and there is no mention whether the output is going to be used for another processing that requires character escaping. The correctness of a solution is judged against its requirements. Second, judging from the OP's question, it

[go-nuts] Re: Generics: after type lists

2020-08-07 Thread 'Carla Pfaff' via golang-nuts
On Saturday, 8 August 2020 at 01:33:59 UTC+2 Patrick Smith wrote: > if we think it likely that a future version of Go will allow operator > overloading > That's highly unlikely: https://golang.org/doc/faq#overloading -- You received this message because you are subscribed to the Google

Re: [go-nuts] How to print arrays with commas and brackets

2020-08-07 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2019-10-09 at 06:02 -0700, Nalin Pushpakumara wrote: > Hi, > I tried to print array with brackets and commas in golang. I want to > get > array like this. > ["record1", "record2". "record3"] > > Does anyone know how to do it? > > Thank you > Not the most efficient, but simple and

Re: [go-nuts] Re: How to print arrays with commas and brackets

2020-08-07 Thread Kurtis Rader
On Fri, Aug 7, 2020 at 7:46 PM Henry wrote: > Or you can do it manually: > > func print(array []string) string { > var buffer strings.Builder > buffer.WriteString("[") > for index, item := range array { > if index != 0 { > buffer.WriteString(", ") > } > buffer.WriteString("\"" + item + "\"") > }

[go-nuts] Re: How to print arrays with commas and brackets

2020-08-07 Thread Henry
Or you can do it manually: func print(array []string) string { var buffer strings.Builder buffer.WriteString("[") for index, item := range array { if index != 0 { buffer.WriteString(", ") } buffer.WriteString("\"" + item + "\"") } buffer.WriteString("]") return buffer.String() } On Wednesday,

[go-nuts] Re: How to print arrays with commas and brackets

2020-08-07 Thread Henry
Or you can do it manually: func print(array []string) string { var buffer strings.Builder buffer.WriteString("[") for index, item := range array { if index != 0 { buffer.WriteString(", ") } buffer.WriteString("\"" + item + "\"") } buffer.WriteString("]") return buffer.String() } On Wednesday,

Re: [go-nuts] "Interfaces" with type lists are a strange beast

2020-08-07 Thread burak serdar
On Fri, Aug 7, 2020 at 7:54 PM Robert Engels wrote: > > I’d really like to see an example of generic code that takes both string and > numeric types that uses operators. Sorting/searching is one but as I already > said the built in string operators are not sufficient for collation cases. > >

Re: [go-nuts] "Interfaces" with type lists are a strange beast

2020-08-07 Thread Robert Engels
I’d really like to see an example of generic code that takes both string and numeric types that uses operators. Sorting/searching is one but as I already said the built in string operators are not sufficient for collation cases. Even generic code that “only works on unsigned types”. More

[go-nuts] Re: why the values in ssa block can be unordered?

2020-08-07 Thread Keith Randall
All the ordering required is explicit in the representation. If x is an argument of y, then x must come before y (in the eventual assembly output). There is no other need for ordering within a basic block. Any order consistent with the argument ordering I mentioned above is ok. On Friday,

Re: [go-nuts] Generics: after type lists

2020-08-07 Thread Kent Sandvik
Operator overloading will never -- hopefully -- be implemented. It's a perfect way to obscurate code. --Kent On Fri, Aug 7, 2020 at 4:33 PM Patrick Smith wrote: > I like the second draft for generics. It seems to me a large > simplification and improvement over the first draft. Considering

[go-nuts] Generics: after type lists

2020-08-07 Thread Patrick Smith
I like the second draft for generics. It seems to me a large simplification and improvement over the first draft. Considering just the state of Go today, I would be quite happy with this, even if it's not perfect. Thanks to Ian, Robert, and everyone else for their work on this. Also, I would vote

[go-nuts] Go 1.15 Release Candidate 2 is released

2020-08-07 Thread Alexander Rakoczy
Hello gophers, We have just released go1.15rc2, a release candidate version of Go 1.15. It is cut from release-branch.go1.15 at the revision tagged go1.15rc2. Please try your production load tests and unit tests with the new version. Your help testing these pre-release versions is invaluable.

Re: [go-nuts] Why gollvm not support race detector?

2020-08-07 Thread Ian Lance Taylor
On Thu, Aug 6, 2020 at 11:33 PM Yuan Ting wrote: > > I know from README that gollvm does not support race detector. Is there any > technical problem? Is it possible to use ThreadSanitizer in LLVM to implement > a workaround race detector in gollvm? ThreadSanitizer knows a great deal about the

Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Ian Lance Taylor
On Fri, Aug 7, 2020 at 12:47 AM Yonatan Gizachew wrote: > > Yeah, but my question is if it is possible to interpose the exported function Yes, it should be possible. Ian > On Friday, August 7, 2020 at 4:25:06 PM UTC+9 Lutz Horn wrote: >> >> Am 07.08.20 um 09:05 schrieb Yonatan Gizachew: >> >

Re: [go-nuts] When does golang use libc for syscall implementation

2020-08-07 Thread Ian Lance Taylor
On Thu, Aug 6, 2020 at 10:13 PM wrote: > > I read somewhere (Very sorry I couldn't get the link now) that golang uses > libc to implement syscalls when the code is built in c-shared mode. I want to > check if this true. When writing to this mailing list, please always send code as plain text

Re: [go-nuts] [generics] type inference on an interface function param

2020-08-07 Thread Ian Lance Taylor
On Thu, Aug 6, 2020 at 7:30 PM wrote: > > having fun with generics I stumbled upon this failure: > https://go2goplay.golang.org/p/Dc3tWrd6RzQ > > Bryan C. Mills helped me to fix it by forcing the type at the call point. > (the comment in the code) > > Forcing a type on a var you just declared is

[go-nuts] why the values in ssa block can be unordered?

2020-08-07 Thread xie cui
https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/block.go#L60 in my opinion, the values are like instructions, why can it be unordered? -- 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] [generics] Trying to make some generic handler

2020-08-07 Thread Ian Lance Taylor
On Thu, Aug 6, 2020 at 7:23 PM wrote: > > I'm quite happy about the generics so far, but now I'm trying some ideas that > I don't know if they are possible or not given the current proposal. > My idea, is to create some kind of generic handler for "net/http" that could > be used in a whole

Re: [go-nuts] How does isAsyncSafePoint check preemptable?

2020-08-07 Thread Ge
Thanks. clear now. 在2020年8月7日星期五 UTC+8 上午1:00:51 写道: > On Thu, Aug 6, 2020 at 7:49 AM HailangGe wrote: > > > > Recently I was trying to understand how asynchronous preemption is > implemented in Go 1.14 and > > basically figured out the call chain. > > > > sysmon > > ↓ > > retake > > ↓ > >

Re: [go-nuts] How to read (and write) the ECN bits?

2020-08-07 Thread Marten Seemann
Thank you guys, your tips were really helpful! Here's the solution I came up with for reading the ECN bits: After setting the IP_RECVTOS options syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_RECVTOS, 1) one can read packets from the socket using n, oobn, flags, addr, err :=

[go-nuts] Re: How to debug the func of makeSlice Or the map creating or growing process step by step

2020-08-07 Thread Brian Candler
To grow a slice, as a programmer you would do: myslice = append(myslice, value) myslice = append(myslice, anotherslice...) Or you can do this my hand, by allocating a new slice of the required size, and copying the elements you want to keep. There is a great overview of how this works

[go-nuts] Re: Modifying Source code and build go from the source.

2020-08-07 Thread 'Carla Pfaff' via golang-nuts
Well, it says "lock_futex.go:152:2: ns declared but not used". An unused variable is a compile error in Go. On Friday, 7 August 2020 at 09:54:23 UTC+2 Yosef Yo wrote: > /home/nn/Downloads/go/src/runtime/lock_futex.go:152:2: ns declared but not > used > > go tool dist: FAILED > -- You

[go-nuts] Modifying Source code and build go from the source.

2020-08-07 Thread Yosef Yo
I wanted to edit one file from the runtime library and build golang from the source (golang version 1.10.4). Without modifying the source code, the build process finished successfully passing all the tests., but after modifying it, the following error appears.

Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Yonatan Gizachew
Yeah, but my question is if it is possible to interpose the exported function On Friday, August 7, 2020 at 4:25:06 PM UTC+9 Lutz Horn wrote: > Am 07.08.20 um 09:05 schrieb Yonatan Gizachew: > > //export Test > > func Test() { > > fmt.Println("test code") > > } > > Yes, now `Test` is exported. >

Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Yosef Yo
Yeah, but my question if interposing this function is possible? On Friday, August 7, 2020 at 4:25:06 PM UTC+9 Lutz Horn wrote: > Am 07.08.20 um 09:05 schrieb Yonatan Gizachew: > > //export Test > > func Test() { > > fmt.Println("test code") > > } > > Yes, now `Test` is exported. > > Lutz > --

Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Lutz Horn
Am 07.08.20 um 09:05 schrieb Yonatan Gizachew: //export Test func Test() { fmt.Println("test code") } Yes, now `Test` is exported. Lutz -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Yonatan Gizachew
Okay, thanks for that. What about now? package main import ( "C" "fmt" ) //export Test func Test() { fmt.Println("test code") } func main() { } On Friday, August 7, 2020 at 3:47:38 PM UTC+9 Lutz Horn wrote: > Am 07.08.20 um 05:00 schrieb eme...@gmail.com: > > //export test > > func test()

Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Lutz Horn
Am 07.08.20 um 05:00 schrieb emeg...@gmail.com: //export test func test() { fmt.Println("test code") } `test` is not exported. It would be, if it was called `Test` with a capital `T`. Lutz -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Why gollvm not support race detector?

2020-08-07 Thread Yuan Ting
Hi, I know from README that gollvm does not support race detector. Is there any technical problem? Is it possible to use ThreadSanitizer in LLVM to implement a workaround race detector in gollvm? Thanks. Ting -- You received this message because you are subscribed to the Google Groups