[go-nuts] Re: Golang and the mobile framework

2020-03-26 Thread husam alkdary
which one react-native or Flutter ? and how ? On Thursday, March 26, 2020 at 8:56:14 AM UTC+2, husam alkdary wrote: > > It's possible to use Golang with to design mobile app with react-native or > Flutter ? > -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: Golang and the mobile framework

2020-03-26 Thread husam alkdary
which one react-native or Flutter ? and how ? On Thursday, March 26, 2020 at 9:46:40 AM UTC+2, Brian Candler wrote: > > Yes. > -- 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,

[go-nuts] Re: Print something while read message from server with websocket

2020-03-26 Thread 洪嘉鴻
Thanks for your replying. I'm sorry that I didn't remind that my Client code does not compile. I've tried your example with SetReadDeadline (). It seems like what I want to do. However, I

[go-nuts] Re: Print something while read message from server with websocket

2020-03-26 Thread 洪嘉鴻
I'm sorry that I didn't remind that my Client code does not compile. I've tried your example with SetReadDeadline (). It seems like what I want to do. Thank you very much! Max Jake

Re: [go-nuts] Re: Slice reuse + GC

2020-03-26 Thread 'Keith Randall' via golang-nuts
It's common practice to *write* to elements between the length and capacity of a slice. Usually, you use append to do that. It's bad practice to *read* elements between the length and capacity. Which you can't do with a simple indexing op, of course. You would have to reslice larger and then

Re: [go-nuts] Go course

2020-03-26 Thread Amnon Baron Cohen
The println and print builtin may be removed from the language in the future. On Thursday, 26 March 2020 19:18:50 UTC, David Riley wrote: > > And since I'm a fan of lifelong learning, I have to admit to not having > known that println() was a builtin until this post. Thanks! That does >

Re: [go-nuts] Re: Slice reuse + GC

2020-03-26 Thread Leszek Kubik
> I disagree. I do that all the time. It's also how `append` was implemented > before it existed as a predeclared function. It's also, FWIW, used in > bytes.Buffer . I agree that > unless your API is very clear about it, you shouldn't really

Re: [go-nuts] Go course

2020-03-26 Thread David Riley
And since I'm a fan of lifelong learning, I have to admit to not having known that println() was a builtin until this post. Thanks! That does un-complicate it somewhat. > On Mar 26, 2020, at 10:34 AM, Sebastien Binet wrote: > > On Thu, Mar 26, 2020 at 3:29 PM David Riley wrote: > [...] >

Re: [go-nuts] Re: Slice reuse + GC

2020-03-26 Thread 'Axel Wagner' via golang-nuts
On Thu, Mar 26, 2020 at 6:57 PM Leszek Kubik wrote: > AFAIK it is allowed to re-slice past the len but it's rather not the way > slices should be ever used. > I disagree. I do that all the time. It's also how `append` was implemented before it existed as a predeclared function. It's also, FWIW,

Re: [go-nuts] Slice reuse + GC

2020-03-26 Thread Leszek Kubik
Actually *T was not a good example to make my point, as we can start debating about the GC walking the references and freeing the data pointed to. However when you have []T, and you refer to some continuous buffer of memory with some chunks [0:5] (gap) [50:100], etc there's not much benefit of

Re: [go-nuts] Slice reuse + GC

2020-03-26 Thread Ian Lance Taylor
On Thu, Mar 26, 2020 at 11:02 AM robfig wrote: > > RE reducing the capacity, I want to distinguish freeing the memory (1) used > for the slice and (2) referred to by the slice elements. I can easily see > that freeing (1) is hard and not so beneficial, but I can't see why (2) would > be

Re: [go-nuts] runtime error: invalid memory address

2020-03-26 Thread Ian Lance Taylor
Check the error returned by template.ParseFiles. Always check error returns. Ian On Thu, Mar 26, 2020 at 10:53 AM wrote: > > Hey guys, > > I'm pretty new to Golang and encountering a runtime error which I'm not able > to fix. > > Need help guys! > >

Re: [go-nuts] Slice reuse + GC

2020-03-26 Thread Leszek Kubik
I let you consider an example: s := make([]*T, 100) s1, s2, s3 := s[:50], s[50:], s[:] ( x lines of code) s1 = s1[:5] Would you like the GC to free the elements past the last s1 slice len? What if s2, s3 are still used somewhere... On Thursday, March 26, 2020 at 7:01:34 PM UTC+1, robfig

Re: [go-nuts] Slice reuse + GC

2020-03-26 Thread robfig
I see, thank you. RE reducing the capacity, I want to distinguish freeing the memory (1) used for the slice and (2) referred to by the slice elements. I can easily see that freeing (1) is hard and not so beneficial, but I can't see why (2) would be difficult, and the benefit seems potentially

[go-nuts] Re: Slice reuse + GC

2020-03-26 Thread Leszek Kubik
AFAIK it is allowed to re-slice past the len but it's rather not the way slices should be ever used. The word slice implies taking a portion from a bigger thing and that's always safe. When you append to the slice however, there's no new allocation if the underlying buffer still has place past

[go-nuts] runtime error: invalid memory address

2020-03-26 Thread davetweetlive
Hey guys, I'm pretty new to Golang and encountering a runtime error which I'm not able to fix. Need help guys! Error***

Re: [go-nuts] Slice reuse + GC

2020-03-26 Thread 'Axel Wagner' via golang-nuts
By the way, I don't think your snippet shows what you think it's showing. In particular, the output stays the same, even if you reduce the capacity to 0: https://play.golang.org/p/r2YvnDNsoBg I also always assumed the GC wouldn't do this optimization (throwing away memory if it's past the capacity

Re: [go-nuts] Slice reuse + GC

2020-03-26 Thread 'Axel Wagner' via golang-nuts
On Thu, Mar 26, 2020 at 6:41 PM robfig wrote: > Reducing a slice's length makes the elements unreachable, but the GC > appears to still treat them as live, based on this snippet: > https://play.golang.org/p/SvsE-nXi-JA > > I would have expected the HeapInUse to go down in the second measurement.

[go-nuts] Slice reuse + GC

2020-03-26 Thread robfig
Reducing a slice's length makes the elements unreachable, but the GC appears to still treat them as live, based on this snippet: https://play.golang.org/p/SvsE-nXi-JA I would have expected the HeapInUse to go down in the second measurement. Why is that? I presume that the GC is traversing

[go-nuts] Re: Print something while read message from server with websocket

2020-03-26 Thread Jake Montgomery
Your Client code does not compile. As a courtesy to those trying to help, it is always good to test your code before posting it. A working example, without your "busy" messages would be something like: https://play.golang.org/p/cvgwd8GDobc . The Read()

Re: [go-nuts] Go course

2020-03-26 Thread Sebastien Binet
On Thu, Mar 26, 2020 at 3:29 PM David Riley wrote: [...] > But: > > - You still need to import something just to print a line, and it is > confusingly (to the novice) named "fmt" > - You still need to declare a function called main(), and most brand-new > programmers don't understand functions

Re: [go-nuts] Go course

2020-03-26 Thread David Riley
I'm aware that Go is not C, and memory management was not one of the points I mentioned. Memory management is a thing that trips up even extremely skilled developers. But I've been programming in C since 1997 and Python since 2010, and I've been working in Go long enough (and teaching new

Re: [go-nuts] Re: json to golang struct definition lib

2020-03-26 Thread sanye
On 3/26/20 4:29 PM, Amnon Baron Cohen wrote: An interesting approach. Slightly surprised you did not use "encodeing/json" to parse the json input, which would have been much easier. Thank you for your advice, I have removed 3rd dependencies, and it is indeed much easier On Thursday, 26

Re: [go-nuts] Re: Mem-Leak in Go method

2020-03-26 Thread Nitish Saboo
Hi Tamas, 1) There is no such option '--heap_inuse'. We have an -*-inuse_space* option. Is this what you are talking about? nsaboo@ubuntu:~/Desktop/memprof$ go tool pprof --inuse_space main mem3.prof Fetched 1 source profiles out of 2 File: main Build ID: 99b8f2b91a4e037cf4a622aa32f2c1866764e7eb

Re: [go-nuts] Why golang allocated memory space increases?

2020-03-26 Thread Henrik Johansson
Isn't this because of the GC tracking these and treating then as effectively weak references to borrow a Java term? If they are not pointers they are not tracked by the GC and I guess they could all be removed at every scan? Just guessing though, I haven't in any way checked it. On Thu, Mar 26,

Re: [go-nuts] Why golang allocated memory space increases?

2020-03-26 Thread Jakob Borg
On 26 Mar 2020, at 09:51, Tamás Gulácsi mailto:tgulacs...@gmail.com>> wrote: sync.Pool MUST use pointers (*[]byte) I've seen this a lot but I confess I don't understand it. A []byte is essentially a fat pointer, what does it matter if we put that or a *[]byte into the pool? I understand that

Re: [go-nuts] Go course

2020-03-26 Thread Amnon Baron Cohen
Go is not C. C programmers have to master explicit memory management, which is a challenge to new and experience programmers alike. C is a beautiful language. But very low level. Having spent several years programming in Python, I would say that it is much more complicated than Go. It has a

Re: [go-nuts] Why golang allocated memory space increases?

2020-03-26 Thread Tamás Gulácsi
gt; http.StatusInternalServerError, CopyChunkError, "internal server exception") >> } >> >> In above codes, it writes chunk data to buffer pool, and the chunk data >> size is 4MB. When I used golang tool pprof to export memory pprof, there >> about 8MB space h

[go-nuts] Re: json to golang struct definition lib

2020-03-26 Thread Amnon Baron Cohen
An interesting approach. Slightly surprised you did not use "encodeing/json" to parse the json input, which would have been much easier. On Thursday, 26 March 2020 00:05:01 UTC, sanye wrote: > > Hello gophers, > > I found an interesting project: https://github.com/mholt/json-to-go , > which

[go-nuts] Re: Golang and the mobile framework

2020-03-26 Thread Brian Candler
Yes. -- 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 the web visit

Re: [go-nuts] Why golang allocated memory space increases?

2020-03-26 Thread steve tang
"internal server exception") > } > > In above codes, it writes chunk data to buffer pool, and the chunk data > size is 4MB. When I used golang tool pprof to export memory pprof, there > about 8MB space has been allocated. Could somebody help me why golang > a

[go-nuts] Golang and the mobile framework

2020-03-26 Thread husam alkdary
It's possible to use Golang with to design mobile app with react-native or Flutter ? -- 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