Re: [go-nuts] Re: Flushing keyboard buffer (cross platform) ?

2019-05-03 Thread Robert Engels
Since people keep referring to “flush”. I’ll chime in again. Thus is not the correct way to do this, as many routines buffer input. Flushing the driver does nothing to characters already in the buffer. Flushing the driver is only appropriate if also doing direct reads from the driver - if you

Re: [go-nuts] binary.Read cgo fields

2019-05-03 Thread Matt Harden
Why do you think binary.Read should handle padding for you? Based on the documentation, it would be a bug if it did. On Tue, Apr 30, 2019 at 4:42 AM Immueggpain S wrote: > I guess I have no other choice then? BTW binary.Read shoud handle padding > automatically. > > On Mon, Apr 22, 2019 at

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread andrey mirtchovski
when you terminate a process the virtual memory associated with that process ceases to exist. any real memory associated with that process is not addressable anymore. if another process allocates a page that maps to a page previously held by the first process will get a zeroed-out page. you

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Wagner Riffel
Last "kkk" print It's not a compiler error due GC, it's just a scoping rule. You shouldn't rely on any GC behaviour, GC is not even definied in Go language spec and its behaviour changes almost every release. BR. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Kurtis Rader
On Fri, May 3, 2019 at 7:25 PM wrote: > Example: > var kk int; > > func main() { > kk= 22 > { kkk := 10 >println ( kkk, kk) > } > println ( kk) > //println (kkk) //compiler error bec at this point kkk has been > destroyed by GC > No. Wrong. The compiler issues

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread lgodio2
Andrey..This is one one the better ones I've seen ..but clearly parts II and III of this article are still in the making. Example: var kk int; func main() { kk= 22 { kkk := 10 println ( kkk, kk) } println ( kk) //println (kkk) //compiler error bec at this

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread andrey mirtchovski
https://www.ardanlabs.com/blog/2018/12/garbage-collection-in-go-part1-semantics.html -- 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

Re: [go-nuts] Re: Flushing keyboard buffer (cross platform) ?

2019-05-03 Thread Matt Harden
You may want http://godoc/github.com/pkg/term/termios. It looks like it supports Tcflush on UNIX, including Solaris: https://github.com/pkg/term/blob/master/termios/termios_solaris.go#L63. On Fri, May 3, 2019 at 9:45 AM gbarr wrote: > For BSD systems I think you need to use TIOCFLUSH instead of

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread lgodio2
I'm currently working on a specialized encryption system where the keys are global... More importantly, I've been unable to locate any decent on-line docs describing exactly how Go GC works from a functional programming perspective..I found some docs describing various GC concepts and others

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Wagner Riffel
> Does Go GC destroy all global vars prior to the end of main() ? What do you expected to happen? it makes no sense GC do any work, at moment a process exits it's OS's job to unmmap allocated pages. FWIW if race detector is enabled runtime does one thing before exit syscall is invoked: if

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Andy Balholm
When the program exits, the operating system releases all the memory allocated to it. So the GC doesn’t need to bother with freeing the memory. Andy > On May 3, 2019, at 5:49 PM, Matt Harden wrote: > > On Fri, May 3, 2019, 17:28 mailto:lgod...@gmail.com>> > wrote: > Does Go GC destroy all

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Matt Harden
On Fri, May 3, 2019, 17:28 wrote: > Does Go GC destroy all global vars prior to the end of main() ? > What do you mean by "destroy"? Go is not an object oriented language and doesn't have the concept of a destructor. So no, it doesn't, but it also doesn't need to. May I ask, what led you to

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread Ivan Medoedov
Thanks very much. This is all very interesting. On Sat, May 4, 2019 at 2:20 AM wrote: > I don't have hard numbers on slowdowns. It will depend a lot on the binary > in question. > At the time I checked the compiler and linker and it did not slow those > down (to the accuracy of our benchmarks).

[go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread lgodio2
Does Go GC destroy all global vars prior to the end of main() ? -- 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

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread keith . randall
I don't have hard numbers on slowdowns. It will depend a lot on the binary in question. At the time I checked the compiler and linker and it did not slow those down (to the accuracy of our benchmarks). The linker particularly is fairly read syscall intensive. We've seen benchmarks that have

Re: [go-nuts] Is it possible to use the Go linker to link C object files?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 4:25 PM wrote: > > Go linker is amazing. It's the only truly cross platform linker. > > Is it possible to use it to create binaries from object files compiled with C? Not really. It only really understands Go code. It understands just enough C code to handle internal

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 3:36 PM wrote: > > I know that calling C functions via cgo is relatively expensive because of > the goroutines, so there must be some optimizations/tricks to make all these > libc calls fast. Yes, this only uses part of the cgo call path, not all of it. In particular

[go-nuts] Is it possible to use the Go linker to link C object files?

2019-05-03 Thread ivan . medoedov
Go linker is amazing. It's the only truly cross platform linker. Is it possible to use it to create binaries from object files compiled with C? For example main.c: int main() { puts("Hello"); return 0; } gcc -c -o main.o main.c go tool link main.o main.o: not package main -- You received

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread ivan . medoedov
I know that calling C functions via cgo is relatively expensive because of the goroutines, so there must be some optimizations/tricks to make all these libc calls fast. On Saturday, May 4, 2019 at 12:21:27 AM UTC+2, ivan.m...@gmail.com wrote: > > Indeed, it works with Go 1.12. I have 3

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 3:21 PM wrote: > > Indeed, it works with Go 1.12. I have 3 different Go versions, and my > aliasing was messed up. Sorry. > > > No. The Linux kernel, fortunately, supports static linking and provides a > > stable syscall API. There is no reason to make this change on

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread ivan . medoedov
Indeed, it works with Go 1.12. I have 3 different Go versions, and my aliasing was messed up. Sorry. > No. The Linux kernel, fortunately, supports static linking and provides a stable syscall API. There is no reason to make this change on GNU/Linux. Good to know, thanks. So Linux, BSD,

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 11:19 AM wrote: > > Am I missing something ?? > When u say : > For any function F and some type T declared asfunc F(x ...T) {} > within F x will have type []T. You can call F with a slice s of type []T as > F(s...) > > Why is this needed ?? What's the point of using

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 11:38 AM wrote: > > I read the following from one of the contributors: > > > On Solaris (and Windows), and more recently in macOS as well we link with > > libc (or equivalent). > > Go used to do raw system calls on macOS, and binaries were occasionally > > broken by

Re: [go-nuts] Re: If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread andrey mirtchovski
macOS doesn't support static linking user binaries. in fact I do see libSystem linked for each go binary on my Mojave system, including the simplest non-outputting hello world: $ cat > t.go package main; func main(){} $ go build t.go && otool -L t t: /usr/lib/libSystem.B.dylib (compatibility

[go-nuts] Re: Exporting and renaming

2019-05-03 Thread michael . f . ellis
Oops, meant to type GoRename instead of GoVet On Friday, May 3, 2019 at 4:05:59 PM UTC-4, michae...@gmail.com wrote: > > Thanks, Tamás. That worked. Still a bit tedious since GoVet was taking > about 6 seconds to rename all the instances of each struct field. But it's > done now. > > On

[go-nuts] Re: Exporting and renaming

2019-05-03 Thread michael . f . ellis
Thanks, Tamás. That worked. Still a bit tedious since GoVet was taking about 6 seconds to rename all the instances of each struct field. But it's done now. On Friday, May 3, 2019 at 3:58:34 PM UTC-4, Tamás Gulácsi wrote: > > Rename the struct fields first, then move it to its own package.

[go-nuts] Exporting and renaming

2019-05-03 Thread Tamás Gulácsi
Rename the struct fields first, then move it to its own package. -- 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

[go-nuts] Re: If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread howardcshaw
I believe that by default, Go programs are statically linked. >From the man page for otool: *-L* Display the names and version numbers of the shared libraries that the object file uses, as well as the shared library ID if the file is a shared library. This

[go-nuts] Exporting and renaming

2019-05-03 Thread michael . f . ellis
I want to make part of my main package into an internal package. It's only one file and I only need to export a single struct type and one function. Seemed easy enough -- just git mv the file to ../internal/ and use GoRename in vim. Problem is that all the struct fields are lowercase and

[go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread ivan . medoedov
Hello, I read the following from one of the contributors: > On Solaris (and Windows), and more recently in macOS as well we link with libc (or equivalent). > Go used to do raw system calls on macOS, and binaries were occasionally broken by kernel updates. Now Go uses libc on macOS. I just

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread lgodio2
Am I missing something ?? When u say : For any function F and some type T declared asfunc F(x ...T) {} within F x will have type []T. You can call F with a slice s of type []T as F(s...) Why is this needed ?? What's the point of using this "crypto-syntax" rather than just declaring the

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 10:24 AM Louki Sumirniy wrote: > > Whenever I write appends and I'm splicing slices together, I often get an > error saying the second slice is the wrong type (it wants the slice element > type). So, doesn't that mean the trailing ellipsis is like an iterator > feeding

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 8:25 AM Louki Sumirniy wrote: > > https://en.wikipedia.org/wiki/Unicode#General_Category_property > > This section in the wp entry lists these categories. > > So, in Go, actually, all identifiers can be in practically any language. Even > many of those funny african

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Burak Serdar
On Fri, May 3, 2019 at 11:24 AM Louki Sumirniy wrote: > > Whenever I write appends and I'm splicing slices together, I often get an > error saying the second slice is the wrong type (it wants the slice element > type). So, doesn't that mean the trailing ellipsis is like an iterator > feeding

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Marcin Romaszewicz
Consider this: var something []interface{} var anotherThing []SomeType append(something, anotherThing) Does the compiler know here whether I want to append "anotherThing" or " anotherThing..."? It has no way to know, and both would work, so that's why we give it a hint with the ellipsis symbol.

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Louki Sumirniy
Whenever I write appends and I'm splicing slices together, I often get an error saying the second slice is the wrong type (it wants the slice element type). So, doesn't that mean the trailing ellipsis is like an iterator feeding out one element at a time? Is there some reason this is needed,

Re: [go-nuts] Re: Should IP.DefaultMask() exist in today's Internet?

2019-05-03 Thread Louki Sumirniy
You'll probably be amused to know that I started studying for Network+ but didn't hold the job long enough to finish it. Hence my somewhat muddled chatter about it. I'm one of those people who usually starts with a brief overview and only digs into details when the task directly requires it,

[go-nuts] Re: Flushing keyboard buffer (cross platform) ?

2019-05-03 Thread gbarr
For BSD systems I think you need to use TIOCFLUSH instead of TCFLSH On Friday, May 3, 2019 at 1:28:36 PM UTC+1, Steve Mynott wrote: > > I've a terminal app where I read y/n confirm using fmt.Scanln and I'm > trying to flush the keyboard buffer before this. > > On linux (and probably other UNIX

Re: [go-nuts] Re: Does fmt.Fprint use WriteString ?

2019-05-03 Thread Robert Engels
Parallelization is another story. If the cores are available and the workload fits, you can get linear speed ups - especially when the IO is parallelized across devices - which is nearly impossible via micro cpu optimizations. > On May 3, 2019, at 10:01 AM, Louki Sumirniy > wrote: > > You

[go-nuts] BCE and stdlib

2019-05-03 Thread Louki Sumirniy
https://i.postimg.cc/BbQDrTy1/Screenshot-from-2019-05-03-18-06-02-2x.png I installed a few nicknacks today after reading stuff about BCE and escape analysis, and made some change to my config and now vscode is showing me all the bounds checks. There is a LOTTA bounds checks in the standard

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Louki Sumirniy
https://en.wikipedia.org/wiki/Unicode#General_Category_property This section in the wp entry lists these categories. So, in Go, actually, all identifiers can be in practically any language. Even many of those funny african scripts and west asian languages! On Friday, 3 May 2019 17:17:56

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Jan Mercl
On Fri, May 3, 2019 at 5:14 PM Louki Sumirniy wrote: > If the 'letter' classification is the same as used in .NET's unicode > implementation, this info lists the categories of symbols that unicode > classifies as letters: https://golang.org/ref/spec#Characters In The Unicode Standard

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Louki Sumirniy
If the 'letter' classification is the same as used in .NET's unicode implementation, this info lists the categories of symbols that unicode classifies as letters: https://docs.microsoft.com/en-us/dotnet/api/system.char.isletter?view=netframework-4.8 On Friday, 3 May 2019 17:11:55 UTC+2, Louki

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Louki Sumirniy
Oh, I *can* use UTF-8 in identifiers?? nooo: Identifiers name program entities such as variables and types. An identifier is a sequence of one or more letters and digits. The first character in an identifier must be a letter. identifier = letter { letter | unicode_digit } . ... Letters

Re: [go-nuts] Re: Does fmt.Fprint use WriteString ?

2019-05-03 Thread Louki Sumirniy
You are totally correct about this - the only real performance booster for IO bound operations is buffering, which delays the writes to be less frequent or follow a clock. I wrote a logging library that used channels, and it was pointed out to me that this doesn't have a big effect. But I

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread JuciÊ Andrade
I think my poor choice of words induced a misunderstanding. When I said "we code in Portuguese" I meant "we prefer to pick words from Portuguese for identifiers". Sorry. On Friday, May 3, 2019 at 11:43:09 AM UTC-3, Ian Lance Taylor wrote: > > On Fri, May 3, 2019 at 7:28 AM Louki Sumirniy > >

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Louki Sumirniy
Ellipsis makes the parameter type into a slice, but in append it makes the append repeat for each element, or do I misunderstand this? There is a syntactic distinction between them too. Parameters it is a prefix to the type, append it is a suffix to the name. It neatly alludes to the direction

Re: [go-nuts] Re: Does fmt.Fprint use WriteString ?

2019-05-03 Thread Robert Engels
I suggest that it might benefit you to understand cost of IO. In most systems the IO cost dwarfs the CPU cost of optimizations like these. I am not saying it never matters - I have significant HFT experience and sone HPC - but in MOST cases it holds true. So micro optimizing the CPU usually

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 7:34 AM Louki Sumirniy wrote: > > The ellipsis has two uses in Go, one is in variadic parameters, the other is > in the slice append operator. It is essentially an iterator that takes a list > and turns it into a slice (parameters) or takes a slice and turns it into a >

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 7:28 AM Louki Sumirniy wrote: > > It would be incredibly computationally costly to add a natural language > translator to the compilation process. I'm not sure, but I think also > identifiers in Go can only be plain ASCII, ie pure latin script (and initial > character

[go-nuts] Re: Go Profiling helper extension for VSCode

2019-05-03 Thread Louki Sumirniy
Ah, just want to give a big thanks for making this tool, I will be needing to do a lot of optimisation in a few weeks once I finish all the implementation and initial debugging. This should help a lot. On Monday, 22 April 2019 16:20:04 UTC+2, mediam...@gmail.com wrote: > > Hello, > > > we have

[go-nuts] Re: Does fmt.Fprint use WriteString ?

2019-05-03 Thread Louki Sumirniy
There is a big difference between the parameters of these two functions. One is a slice of interface, the other is only a a single string parameter. fmt print functions all have nasty messy interface switching and reflection internally hence the significant overhead. A lot of people clearly

[go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Louki Sumirniy
It would be incredibly computationally costly to add a natural language translator to the compilation process. I'm not sure, but I think also identifiers in Go can only be plain ASCII, ie pure latin script (and initial character must be a letter) These days in most countries where foreign

[go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Louki Sumirniy
The ellipsis has two uses in Go, one is in variadic parameters, the other is in the slice append operator. It is essentially an iterator that takes a list and turns it into a slice (parameters) or takes a slice and turns it into a recursive iteration (append). Parameters with the ellipsis are

[go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Louki Sumirniy
I'd also go further and point out that the Go language has a somewhat peculiar and unique feature that code reusability is not considered a holy grail. If I really needed a library that was written in portuguese, it would not be hard to figure out how to rename everything for my easier

Re: [go-nuts] multiple array declaration.. Is there a easier way ?

2019-05-03 Thread Louki Sumirniy
It looks like it should be an array T to me, then: var T = [5][256]uint32 On Thursday, 2 May 2019 03:45:07 UTC+2, kortschak wrote: > > var T0, T1, T2, T3, T5 [256]uint32 > > https://play.golang.org/p/6Cm4p_NyD8m > > On Wed, 2019-05-01 at 18:40 -0700, lgo...@gmail.com wrote: > > The following

Re: [go-nuts] Re: Random panic in production with Sprintf

2019-05-03 Thread tsilva
Are you using the fasthttp timeout handler? If its the case you could have a race condition once the timeout is triggered. Tiago On Friday, May 3, 2019 at 5:23:58 AM UTC+1, Burak Serdar wrote: > > On Thu, May 2, 2019 at 6:34 PM Tyler Compton > wrote: > > > > I took a quick look and yes, it

Re: [go-nuts] Flushing keyboard buffer (cross platform) ?

2019-05-03 Thread Robert Engels
You can easily write a portable one. Just read and discard until no more available. Then make the call to the input read. > On May 3, 2019, at 7:28 AM, Steve Mynott wrote: > > I've a terminal app where I read y/n confirm using fmt.Scanln and I'm trying > to flush the keyboard buffer before

[go-nuts] Flushing keyboard buffer (cross platform) ?

2019-05-03 Thread Steve Mynott
I've a terminal app where I read y/n confirm using fmt.Scanln and I'm trying to flush the keyboard buffer before this. On linux (and probably other UNIX systems) I can use unix.Syscall(unix.SYS_IOCTL, 0, unix.TCFLSH, 0) but this isn't portable (specifically to macOS which it would be nice to

Re: [go-nuts] Extend map with another map

2019-05-03 Thread Robert Engels
I think the most straight forward way in go is just use 2 calls (pseudo) done:= handleVerbs(g.Verbs) If !done && includeSysVerbs { handleVerbs(sys.Verbs) } If it is more involved than that then use an internal delegating to parent pattern and declare a struct like ActionMap, that takes a

[go-nuts] Extend map with another map

2019-05-03 Thread Mark Bauermeister
I'm in the process of writing my own Text Adventure/Interactive Fiction engine/library and am now running into a bit of a problem attempting to extend the parser. On the implementation side (i e a game), this is how a game is initially set up. game = mid.Game{ Title: "Cloak of

Re: [go-nuts] Re: Should IP.DefaultMask() exist in today's Internet?

2019-05-03 Thread Wojciech S. Czarnecki
On Thu, 2 May 2019 17:22:15 -0700 (PDT) Louki Sumirniy wrote: > I'm quite aware of that it's part of the ARP, and allows the router to https://tools.ietf.org/html/rfc826 [read updates too] Main source of the knowledge of Internet internals is publicly available at

Re: [go-nuts] Re: Should IP.DefaultMask() exist in today's Internet?

2019-05-03 Thread Louki Sumirniy
Well, talking about faults in the stdlib opens a whole can of worms. There is more than a few in there that have code that is quite non-idiomatic, and some needs serious optimisation... And while there is a clear aim to not unnecessary complicate the compiler, I think there is a lot that can be

[go-nuts] Re: Excel XLSX to read/write without losing of formatting

2019-05-03 Thread plandem
Library updated again: - added full support of hyperlinks - added full support of merged cells - refactored formatting to improve usage - other small changes v1.0.0 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group