Re: [go-nuts] Usage example inside a lib project

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 2:35 PM Federico Paolinelli wrote: See https://golang.org/pkg/testing/#hdr-Examples. Put the examples into the foo_test.go file. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] The Go code formatter

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 1:24 PM Ali Altun wrote: > There is a code part in the https://golang.org/pkg/sort/#example_ > The Go code formatter doesn't change this code. The code is already gofmt'ed, so no change is expected. > Similarly, how can I make it leave the

Re: [go-nuts] [NEWBIE] syncmap - how to use it correctly

2018-04-13 Thread Jan Mercl
On Fri, Apr 13, 2018 at 2:29 PM wrote: > What i do wrong? The code relies on the bool value in 'ok', returned from .Load(), but that _does not_ mean some other goroutine, once you remove the mutex.Lock(), cannot insert a value for the same key the moment the call of

Re: [go-nuts] [NEWBIE] what means importing a file versus a directory?

2018-04-11 Thread Jan Mercl
On Wed, Apr 11, 2018 at 3:21 PM Robert P. J. Day wrote: > ... -- what does it mean > to import a name that is a single .a file versus importing a directory > name from under GOROOT (in my case, on fedora, /usr/lib/golang). You mostly cannot really import a file and

Re: [go-nuts] alternate struct tags for json encode/decode?

2018-04-11 Thread Jan Mercl
On Wed, Apr 11, 2018 at 2:50 PM Reed Wade wrote: > Is there a sensible existing way to do that? Would this be a useful update to the lib? Not very nice, but: https://play.golang.org/p/gkWEuV1AlwB -- -j -- You received this message because you are subscribed to the

Re: [go-nuts] Sorting slice of structs

2018-04-10 Thread Jan Mercl
On Tue, Apr 10, 2018 at 8:29 PM Sankar wrote: > Any help on how I can get arr sorted in the above code ? Just a typo: https://play.golang.org/p/vhbo8OIrh-H -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] formatting question/issue

2018-04-10 Thread Jan Mercl
On Tue, Apr 10, 2018 at 1:32 AM Alex Dvoretskiy wrote: > Why there is no difference if the last comma exists? Because the language specification allows to omit the last comma before the closing '}': LiteralValue = "{" [ ElementList [ "," ] ] "}" . See:

Re: [go-nuts] Regexp: Matching a new line but *not* start of string, from a Reader

2018-04-09 Thread Jan Mercl
On Mon, Apr 9, 2018 at 4:37 PM Alex Efros wrote: > I've just tried it with strings.Reader and found current seek position > after FindReaderSubmatchIndex is in 3 bytes after end of the match: > https://play.golang.org/p/OJT7Ri8ji2C Maybe

Re: [go-nuts] Regexp: Matching a new line but *not* start of string, from a Reader

2018-04-09 Thread Jan Mercl
On Mon, Apr 9, 2018 at 6:47 AM Paul Lalonde wrote: > Any advice? If regexp cannot solve your task don't use regexp. Write the tiny state machine by yourself, it should be not too much code. -- -j -- You received this message because you are subscribed to the

Re: [go-nuts] Re: Is there a memory leak on Rob Pike's demo codes?

2018-04-05 Thread Jan Mercl
On Thu, Apr 5, 2018 at 9:10 AM T L wrote: > yes. it is a resource leak. It's not necessarily a leak. It's a possible leak. And digging even deeper: it's implementation defined. Non-reachable channels can be collected and goroutines blocked on them killed without changing

Re: [go-nuts] func or if in many return

2018-03-28 Thread Jan Mercl
On Wed, Mar 28, 2018 at 1:20 PM ToSuNuS wrote: > Is there a way to write this more smoothly, or is there no problem with the function? Hard to tell. What you've posted seems to not conform to the Go grammar. Please try to share the snippet using the Go playground (

Re: [go-nuts] Can I be certain that the default branch of a select will never be selected when case channels are always be writable / readable?

2018-03-22 Thread Jan Mercl
On Thu, Mar 22, 2018 at 4:46 PM wrote: > Can I assume that the code above will never panic? Yes: If one or more of the communications can proceed, a single one that can proceed is chosen via a uniform pseudo-random selection. Otherwise, if there is a default case, that

Re: [go-nuts] Re: About argument evaluation order.

2018-03-20 Thread Jan Mercl
On Tue, Mar 20, 2018 at 6:48 PM Ian Lance Taylor wrote: > In this case I don't agree. The order of evaluation rules make it > clear that the first output is 1 and the last output is 2, but they do > not specify when the value of y is read. I see, I missed the "... and the

Re: [go-nuts] Re: About argument evaluation order.

2018-03-20 Thread Jan Mercl
On Tue, Mar 20, 2018 at 6:19 PM T L wrote: > Yes "1 1 2" is the output of gc, but I can't find any guarantees made for this output in Go specification. The guarantee was mentioned: LTR evaluation order as seen in the specs here:

Re: [go-nuts] Re: About argument evaluation order.

2018-03-20 Thread Jan Mercl
On Tue, Mar 20, 2018 at 5:18 PM T L wrote: > For the following example, the output may be any of "1 7 2", "1 8 2" and "1 9 2"? The output is "1 1 2" due to LTR evaluation order mandated by the specs: https://play.golang.org/p/WorzfBzfOhe -- -j -- You received this

Re: [go-nuts] Best practices for package maintainers

2018-03-19 Thread Jan Mercl
On Mon, Mar 19, 2018 at 1:24 AM Vitor De Mario wrote: > It is a public document, open to any comments and edits. Such documents tend to not live for long. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Re: Would this race condition be considered a bug?

2018-03-18 Thread Jan Mercl
On Sun, Mar 18, 2018 at 6:21 PM Devon H. O'Dell wrote: > * There is no way to force at least 16 byte alignment of data per the language spec, so there is no way to implement DCAS (notably missing from sync/atomic) on amd64 (cmpxchg16b requires 16 byte alignment of its

Re: [go-nuts] an "append" use, bug or intended design?

2018-03-16 Thread Jan Mercl
On Fri, Mar 16, 2018 at 7:40 PM T L wrote: > I feel the second append call should be also valid. Works as intended: T is not struct{} If desired, it can become that: https://play.golang.org/p/nY-BB3t0IAw -- -j -- You received this message because you are subscribed

Re: [go-nuts] About 64bits alignment

2018-03-15 Thread Jan Mercl
On Thu, Mar 15, 2018 at 3:29 PM T L wrote: > I mean "always makes 64-bit words 64-bit aligned on i386 OSes." AFAIK, that's not the case, ie. not always. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Is there any tutorial or documentation on getting flame graphs with go 1.10?

2018-03-13 Thread Jan Mercl
On Tue, Mar 13, 2018 at 3:35 PM Sathish VJ wrote: > Trying to figure out profiling and flame graphs on the latest go. And information seems to be lacking. Any pointers to articles that work? https://github.com/uber/go-torch -- -j -- You received this message because

Re: [go-nuts] Is channel push atomic?

2018-03-08 Thread Jan Mercl
On Fri, Mar 9, 2018 at 8:19 AM Andrey Tcherepanov < xnow4fippy...@sneakemail.com> wrote: > So if this is a "just" a mutex, this whole thing will not be atomic - it would introduce intermediate (albeit invisible) between "<-" parts. I was hoping for the "edge collapse" here. Not sure IIUC, but I

Re: [go-nuts] Is channel push atomic?

2018-03-08 Thread Jan Mercl
On Fri, Mar 9, 2018 at 7:47 AM Andrey Tcherepanov < xnow4fippy...@sneakemail.com> wrote: > ch <- <-ch // Is this an atomic operation? Channel send and receive operations are safe wrt to concurrency. That may be seen atomic in a certain sense: only one goroutine at a time can ever perform such

Re: [go-nuts] glr support in goyacc?

2018-03-08 Thread Jan Mercl
On Thu, Mar 8, 2018 at 7:44 PM David Wahlstedt < david.wahlstedt@gmail.com> wrote: > So, if golang has been bootstrapped, compiled with itself, how did they write the parser? > By hand, or by using an LR parser and tweaking the grammar? Go authors initially used a modified grammar (distilled

Re: [go-nuts] w, x += i, i+i

2018-03-05 Thread Jan Mercl
On Mon, Mar 5, 2018 at 1:42 PM wrote: > .. isn't the EBNF at https://golang.org/ref/spec#Assignments currently wrong - in that it allows what is currently disallowed The EBNF is just a part of the specification that defines the grammar. Other parts of the specification

Re: [go-nuts] fast small prime checker

2018-03-04 Thread Jan Mercl
On Mon, Mar 5, 2018 at 12:55 AM wrote: > For my use case, I'll only be checking numbers > 2^18 and < 2^25. After looking at the repo, it's not simple enough to copy primes.go, anyone that wants to rely on it would have to fork the repo. No need to copy source code or

Re: [go-nuts] fast small prime checker

2018-03-04 Thread Jan Mercl
On Sun, Mar 4, 2018 at 9:38 PM wrote: > The performance looks to be as good or slightly better than my simple implementation. FTR, the performance is in an order of magnitude, or as you put it "slightly", better in the case of uint32 - and probably several orders of

Re: [go-nuts] fast small prime checker

2018-03-04 Thread Jan Mercl
On Sun, Mar 4, 2018 at 7:27 AM wrote: > It still has room for optimization, but it is much faster than ProbablyPrime(0) for 32-bit integers. > http://nerdralph.blogspot.ca/2018/03/fast-small-prime-checker-in-golang.html You may want to give the primality checking

Re: [go-nuts] copy is not very essential function? It can always be simulated by append?

2018-03-01 Thread Jan Mercl
On Thu, Mar 1, 2018 at 5:13 PM wrote: > _ = append(b[1:1], b[:len(b)-1]...) Bad reading, my fault. Anyway, I think it should now be clear that append depends on the 'inteligence' of copy as it knows when to move things around from the beginning and when to start from the

Re: [go-nuts] copy is not very essential function? It can always be simulated by append?

2018-03-01 Thread Jan Mercl
On Thu, Mar 1, 2018 at 4:50 PM wrote: > copy(a[1:], a) is equivalent to _ = append(s[1:1], s[:len(s)-1]...) https://play.golang.org/p/uiz2ANSxjbA -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] copy is not very essential function? It can always be simulated by append?

2018-03-01 Thread Jan Mercl
On Thu, Mar 1, 2018 at 4:28 PM wrote: > is the statement right? It depends on the POV. I see copy as more fundamental than append. It's easy to write append using copy, not exactly trivial the other way around. Consider cases like copy(a[], a[1:]) or copy(a[1:], a). -- -j

Re: [go-nuts] Interface ????

2018-02-27 Thread Jan Mercl
On Tue, Feb 27, 2018 at 4:25 PM wrote: > Why doesn't work this : Because types []string and []interface{} are different and not assignable to each other. > and Why does it work? : Because type string implements interface{} (as any other type does), string is assignable to

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-26 Thread Jan Mercl
On Tue, Feb 27, 2018 at 8:17 AM wrote: > ok, this is really make gophers worry about whether or not the pointer atomic functions should be used. What to worry about? Under the Go 1 compatibility promise, the sync/atomic package is going nowhere, IIUC. -- -j -- You

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-25 Thread Jan Mercl
On Sun, Feb 25, 2018 at 3:20 PM wrote: > I think the unsafe rules allow this. Yes, but using unsafe provides no guarantees about writable memory. > I never expect it will crash, for I can't get any information about the write protection mechanism. That's not part of the

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-25 Thread Jan Mercl
On Sun, Feb 25, 2018 at 2:29 PM wrote: > Why does the following program crash? Because the program attempts to write to the R/O text segment. Why is it doing that? -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Is this a bug?

2018-02-25 Thread Jan Mercl
On Sun, Feb 25, 2018 at 10:23 AM Bakul Shah wrote: > Why not case T2? It does match T2 as well. The order of cases of the type switch maters: https://play.golang.org/p/nb28xHQP7oU -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] strings.Split behavior

2018-02-20 Thread Jan Mercl
On Tue, Feb 20, 2018 at 9:51 PM wrote: > But instead the second fmt.Println() output implies that it grabbed more than one word. > > I'm a noob and puzzled by this behavior. I don't know how the concept of word got involved in the "expected" behavior, but the code shown has

Re: [go-nuts] Appropriate Go type for cgo void* param that accepts either an offset or pointer?

2018-02-19 Thread Jan Mercl
On Mon, Feb 19, 2018 at 8:35 PM Eric Woroshow wrote: > Using uintptr might work, but my concern is that passing a Go pointer into C by way of a uintptr value might confuse the GC (specifically, that the memory would fail to be pinned if/when Go implements a moving GC).

Re: [go-nuts] Re: Question about casting

2018-02-18 Thread Jan Mercl
On Sun, Feb 18, 2018 at 8:06 PM Bill Wood wrote: > I thought that the plus operator would return an int, not a myInt. expr1 + expr2 works iff types of expr1 and expr2 are the same and the result has the same type as both of the operands. Analogically for the subtraction,

Re: [go-nuts] printing a struct fields that implements an error interface

2018-02-18 Thread Jan Mercl
On Sun, Feb 18, 2018 at 1:06 AM Joseph Lorenzini wrote: > Is there anyway to force fmt.Print to output the struct fields, even when it implements the error interface? What exactly do you mean by "to output the struct fields"? -- -j -- You received this message because

Re: [go-nuts] Okay to use mmap ?

2018-02-13 Thread Jan Mercl
On Tue, Feb 13, 2018 at 4:28 PM Ian Lance Taylor wrote: > I think that will work today but we make no promise that it will > continue to work in the future. In particular it will fail if the > garbage collector ever starts to move objects. Right, I forgot about that and thanks

Re: [go-nuts] Okay to use mmap ?

2018-02-13 Thread Jan Mercl
On Tue, Feb 13, 2018 at 12:40 AM wrote: > Note though that you can't put pointers to Go heap objects into mmap'd memory, as the garbage collector can't see them. It's possible, provided such pointers are known/guaranteed to be reachable from any memory maintained

Re: [go-nuts] Okay to use mmap ?

2018-02-12 Thread Jan Mercl
On Mon, Feb 12, 2018 at 5:28 PM Juliusz Chroboczek wrote: > Is it okay to use syscall.Mmap to allocate large amounts of memory, or > will it conflict with Go's memory allocator? >From my experience it's ok. Shameless plug: You might want to have a look at a

Re: [go-nuts] [Question] database/sql

2018-02-08 Thread Jan Mercl
On Thu, Feb 8, 2018 at 2:29 PM Mandolyte wrote: > I want to load it at run time. Is this possible? Why? The driver code is already linked into your program, otherwise you would not be able to load it later. -- -j -- You received this message because you are subscribed

Re: [go-nuts] Struct literal in condition of if statement yields compile error

2018-02-06 Thread Jan Mercl
On Tue, Feb 6, 2018 at 10:31 PM Patrick Smith wrote: > Obviously I can code around this, but is it a bug that should be reported? Not a bug. See https://golang.org/ref/spec#Composite_literals A parsing ambiguity arises when a composite literal using the TypeName

Re: [go-nuts] Re: unused import and variables, necessary at compiler level? Experience can be improved?

2018-02-01 Thread Jan Mercl
On Thu, Feb 1, 2018 at 4:26 PM wrote: > You can also use _ to store unused variables. Like this: That works, but I do not recommend to do that. The temporary '_= foo' workaround is too easy to miss and it can stay accidentaly left in production code. The earlier

Re: [go-nuts] question

2018-02-01 Thread Jan Mercl
On Thu, Feb 1, 2018 at 8:39 AM 王晚成 wrote: '&' Expression takes the address of an addressable expression. '&' Type '{' ... '}' creates an instance of T (restrictions apply) and returns the address of the instance. -- -j -- You received this message because you are

Re: [go-nuts] unused import and variables, necessary at compiler level? Experience can be improved?

2018-01-31 Thread Jan Mercl
On Thu, Feb 1, 2018 at 3:46 AM Alex Buchanan wrote: Put this line into any of the package *_test.go files: func use(...interface{}) {} When disabling some code in non-test files leads to unused variables foo and baz error, insert `use(foo, bar)` there to keep

Re: [go-nuts] Why []Interface{} indexing failing at if statement

2018-01-29 Thread Jan Mercl
On Mon, Jan 29, 2018 at 12:36 PM pradam wrote: > //here its throwing error like: non-boolean condition in if statement The compiler is right. 'arr' is not a boolean expresion, its type is 'interface{}'. Try: https://play.golang.org/p/zwNV9RD2oCs. -- -j -- You

Re: [go-nuts] Re: How to pass Go []byte (arrays/slices) as C *char to C functions

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 5:02 PM Christian LeMoussel wrote: > Is it correct /best way ? Hopefully/only. But as noted previously, not tested. > There is no memory leaks ? Something must eventually C.free() the memory allocated by C.CString(). -- -j -- You received this

Re: [go-nuts] How to pass Go []byte (arrays/slices) as C *char to C functions

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 4:54 PM Christian LeMoussel wrote: > devidx := C.scan_bus((*C.char([0])), C.int(cap(sbuf)), C.CString(sn), C.CString(product)) Not tested: devidx := C.scan_bus((*C.char)(unsafe.Pointer([0])), C.int(cap(sbuf)), C.CString(sn), C.CString(product)) --

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 4:45 PM dc0d wrote: > In the sample you have provided, a send syntax is used. And considering that, (IMHO) f1() must be evaluated first. Consider f1() is a dispatcher. If it is to be evaluated first then it may create and return a new channel

Re: [go-nuts] gofmt rewrite rules

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 2:03 PM Chris Hopkins wrote: > gofmt -w -r 'a.Set(b,c) -> err:=a.Set(b,c)\nif err != nil{log.Fatal("Set Error",err)}' I think the -r flag can handle only forms like 'expr1 -> expr2', but in this case expr2 is a statement. To my surprise I cannot

Re: [go-nuts] Re: Is there something similar to cmp in python?

2018-01-21 Thread Jan Mercl
On Sun, Jan 21, 2018 at 5:54 PM wrote: > Sounds good to me. I'm not familiar with any performance tradeoffs like branch prediction changes, but I assume the compiler result is equivalent. A sufficiently smart compiler can emit zero conditional branches within CmpX,

Re: [go-nuts] Re: Is there something similar to cmp in python?

2018-01-21 Thread Jan Mercl
On Sun, Jan 21, 2018 at 4:32 PM wrote: All the else clauses should be dropped. -- -j -- 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

Re: [go-nuts] How to import local go files?

2018-01-20 Thread Jan Mercl
only import a > single go file when there are multiple go files in a package > directory? > > On Sat, Jan 20, 2018 at 4:32 PM, Jan Mercl <0xj...@gmail.com> wrote: > > Look for the term "exported" in the language specification. > > > > On Sa

Re: [go-nuts] How to import local go files?

2018-01-20 Thread Jan Mercl
Look for the term "exported" in the language specification. On Sat, Jan 20, 2018, 23:30 Peng Yu wrote: > Why is only Add allowed? Where is this documented? > -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] How to import local go files?

2018-01-20 Thread Jan Mercl
On Sat, Jan 20, 2018 at 9:29 PM Peng Yu wrote: s/add/Add/g -- -j -- 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:

2018-01-18 Thread Jan Mercl
On Fri, Jan 19, 2018 at 7:48 AM Volker Dobler wrote: > Point{1,2} is not a temporary variable but a literal > and these do have addresses. Just not automatically. Did you mean {1, 2}? Otherwise Point{1, 2} is a non-addressable value like 42. Literals do not have

Re: [go-nuts] Core team and internal organisation of go project

2018-01-18 Thread Jan Mercl
On Thu, Jan 18, 2018 at 7:28 PM Davor Kapša wrote: > How many members has core team? > > How are they internally organised? > (How are they organised on daily bases? How many sub teams exist and how are they divided?) > > Are they all on Google salaries? Confidential

Re: [go-nuts] How to use `go test`?

2018-01-18 Thread Jan Mercl
On Thu, Jan 18, 2018 at 5:01 PM wrote: > main_test.go:1:1: illegal character U+0023 '#' The message says it all. Go is not an interpreted scripting language supporting #-style comments like bash, Python etc. -- -j -- You received this message because you are

Re: [go-nuts] how about golang channel memory usage?

2018-01-16 Thread Jan Mercl
On Tue, Jan 16, 2018 at 7:52 AM Lynn H wrote: > but how about res memory usage? how RES memory used in golang? Most process allocations typically do not care about the virtual memory being immediately mapped to physical RAM. The operating systems takes care about that usually

Re: [go-nuts] how about golang channel memory usage?

2018-01-15 Thread Jan Mercl
On Tue, Jan 16, 2018 at 4:49 AM Lynn H wrote: > not understand ur table, > when memsize is 256,single channel use 6114Byte memory? Size of []byte is 3 words, assuming a 64 bit system that's 24 bytes. 256*24 = 6,144 bytes ie. size of a chan []byte with capacity 256, which is

Re: [go-nuts] how about golang channel memory usage?

2018-01-15 Thread Jan Mercl
On Mon, Jan 15, 2018 at 6:04 PM Lynn H wrote: > so what the rules of channel size and memory usage? Check [0] if the formulas are correct. [0]: https://docs.google.com/spreadsheets/d/1BuAnHmBKWfWD9JXXi4_k9ck-rkJyDuQgCQ05s4ytJI8/edit?usp=sharing -- -j -- You received

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Jan Mercl
On Sun, Jan 14, 2018 at 5:37 AM wrote: > I have a parent/child class ... You don't. No classes, no parents, no children. You need to make your design work with Go. In most cases you cannot make Go work like languages supporting classes and inheritance. -- -j --

Re: [go-nuts] error: incompatible types in binary expression

2018-01-10 Thread Jan Mercl
On Wed, Jan 10, 2018 at 2:29 PM pradam wrote: > I am a newbie to golang, I have been working on this snippet for a while whenever i run this snippet I am getting above error message. > I am actual searched on google but i didn't get any proper solution with an

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-10 Thread Jan Mercl
On Tue, Jan 9, 2018 at 10:08 PM Jim Bishopp wrote: > Has there ever been a discussion about allowing new identifiers and selectors in short variable declarations? FTR: There are other things that are legal on the LHS of an assignment, but not in the short variable

Re: [go-nuts] possible to create 32bit windows exe's of my code (for desktop apps) from my 64bit windows 10 machine?

2018-01-09 Thread Jan Mercl
On Tue, Jan 9, 2018 at 2:18 PM evan wrote: > i have a 64bit windows 10 development machine. some of the machines in our production environment are still 32bit windows 8.x and 7.x machines. > > would it be possible for me to create exe's for those 32 bit machines from my

Re: [go-nuts] Is it reasonable?

2018-01-07 Thread Jan Mercl
On Sun, Jan 7, 2018 at 11:57 AM T L wrote: Yes. The choice is to raise a runtime error or not. When not, the value does not really matter because every value of an integer variable represents an integer number and there is no combination of the bits left unused for NaN, Inf,

Re: [go-nuts] Meet "fatal morestack on g0" on Linux

2018-01-06 Thread Jan Mercl
On Sat, Jan 6, 2018, 11:16 wrote: > Thanks for your advice! I got the error message and the pstack result > screenshot from one of our client. I will try to use some OCR tools to > convert the image to text next time. > It's already text, no need for OCR. Just copy the

Re: [go-nuts] Underlying arrays and their slices passed to functions

2018-01-04 Thread Jan Mercl
On Thu, Jan 4, 2018 at 7:08 PM Frank Davidson wrote: > I'm sure this has probably been answered before, but I have a question about when a slice's underlying array is copied? In this code: In your code the underlying arrays are never copied when passed around. -- -j

Re: [go-nuts] Fuzzy behaviour of go test with examples in sort package

2018-01-01 Thread Jan Mercl
On Mon, Jan 1, 2018 at 8:37 PM Kshitij Saraogi wrote: > While running the test suite in the "sort" pacakge, I found that all the examples are not being evaluated. > I tried running `$ go test -v src/sort` from the base directory of the repository. > > The tests such as

Re: [go-nuts] Nil Channels and Case Evaluation

2017-12-31 Thread Jan Mercl
On Sun, Dec 31, 2017 at 4:41 PM dc0d wrote: > Or the (not only) other option is check for nil channels before entering the scope of select? That would remove an equally important property that the RHS can se the channel to nil. tl;dr: The current design was

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2017-12-31 Thread Jan Mercl
On Sun, Dec 31, 2017 at 1:15 PM dc0d wrote: > Also the function first() may block on it's own. That's the very purpose of the select statement! 1. Determine which cases can proceed and which cannot. 2. Randomly select one case which can proceed and perform the

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2017-12-31 Thread Jan Mercl
On Sun, Dec 31, 2017 at 12:48 PM dc0d wrote: > Indeed everything works according to the specs. That is what is being questioned (the specs). Well, questioning the specification and expecting unspecified behavior seems like two different things. > This behavior for

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2017-12-31 Thread Jan Mercl
On Sun, Dec 31, 2017 at 11:55 AM dc0d wrote: > Please read the first message in this thread. The first() function was expected to be ignored as in common sense, yet it gets evaluated. > > I am not wrong (or right), only making a point (maybe the point seems pointless)

Re: [go-nuts] Re: private global un-used variable passing compile - is it intended or a bug?

2017-12-31 Thread Jan Mercl
On Sun, Dec 31, 2017 at 11:47 AM wrote: > But would it make more sense to throw an error in this case? Is there any missing points for an un-used private global variable? I think it's just heuristic. Unused local variable really is an error more often than an unused TLD

Re: [go-nuts] O_DIRECT and write Array returns Invalid argument error

2017-12-29 Thread Jan Mercl
On Fri, Dec 29, 2017 at 10:45 AM Viacheslav Biriukov wrote: > I expect that my alignment write from an array will work as it works with a slice. The code nowhere cares to make the alignment required by O_DIRECT proper for the write. It works in one of the cases just by

Re: [go-nuts] implement something like writeback journal for writing files

2017-12-25 Thread Jan Mercl
On Mon, Dec 25, 2017 at 10:11 AM Vasiliy Tolstov wrote: What about a write ahead log? https://godoc.org/github.com/cznic/file#WAL -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Comparing structs

2017-12-24 Thread Jan Mercl
On Sun, Dec 24, 2017 at 10:53 PM Sofiane Cherchalli wrote: > Any hints on how to pass test? > > https://play.golang.org/p/ucDdBN_jzw7 I have no idea what should be the outcome, just fixed the syntax error: https://play.golang.org/p/CzRn0QwUayw -- -j -- You received

Re: [go-nuts] github repo names with "go-" prefix?

2017-12-24 Thread Jan Mercl
> On Sun, Dec 24, 2017 at 12:31 AM Mariusz Gronczewski wrote: > Because other languages do not force you to have name of the package be derivative of the repo name. Neither does Go. The whole tool chain uses the name in the package clause, the import path is used solely to

Re: [go-nuts] Weird behavior of a nil check after variable redeclaration

2017-12-22 Thread Jan Mercl
Putting anything that has a type in any interface makes it non nil. (*foo)(nil) has a type. On Fri, Dec 22, 2017, 17:38 Vincent Rischmann wrote: > Hello, > > while refactoring some code I encountered something strange regarding > redeclarations. > > Here is an example:

Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Jan Mercl
On Wed, Dec 20, 2017 at 12:57 AM 'Keith Randall' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Pointers that point from a Go object to somewhere outside the Go heap are perfectly fine. Can you please specify the exact mechanism used by the runtime to determine "is outside the Go

Re: [go-nuts] GC Internals Questions

2017-12-19 Thread Jan Mercl
On Tue, Dec 19, 2017 at 1:50 PM Xuanyi Chew wrote: > As such I have no idea what would happen if the GC scanner hits a unsafe.Pointer that it cannot access. Will the pointer be marked as unaccessible? Does it panic with SIGBUS? I think the GC will not try to dereference a

Re: [go-nuts] Compiler Static Optimisation

2017-12-19 Thread Jan Mercl
On Tue, Dec 19, 2017 at 12:05 PM Chris Hopkins wrote: ... > was slower than: ... Without more information the conclusion that the optimization is not there cannot be established. Inspect the real produced machine code. I guess you'll find that the machine code differs in

Re: [go-nuts] Github wiki pages publicly editable

2017-12-14 Thread Jan Mercl
On Thu, Dec 14, 2017 at 5:05 PM Ivan Borshukov wrote: > I've noticed that I'm able to edit the wiki pages on https://github.com/golang/go/wiki and I wonder whether this is intentional. IINM, it's like that from the beginning of the Github repository, so probably

Re: [go-nuts] go generate ignores files ignored for build

2017-12-14 Thread Jan Mercl
On Thu, Dec 14, 2017 at 11:53 AM dc0d wrote: > What is the reasoning for not executing //go:generate ... comments inside a file, that is excluded from build by // +build ignore? 'ignore' is just a tag like any other: $ cat main.go // +build ignore //go:generate

Re: [go-nuts] Re: Learning Go: suggestions for code review?

2017-12-14 Thread Jan Mercl
On Thu, Dec 14, 2017 at 6:27 AM Nigel Tao wrote: > As per https://golang.org/doc/effective_go.html#mixed-caps ALL_CAPS > names are unusual Go style. They are, but token names are often/traditionally all caps and underscores: https://golang.org/pkg/go/token/#Token - in the

Re: [go-nuts] Re: Go Compiler How Work?!

2017-12-13 Thread Jan Mercl
On Wed, Dec 13, 2017 at 1:20 PM wrote: > Could you first answer this question? The problem is that so far no one seems to be able to understand some/most of your questions. Please try asking using more words of explanation. The added context may hopefully help others to

Re: [go-nuts] Unused Variable Generates No Error

2017-12-13 Thread Jan Mercl
On Wed, Dec 13, 2017 at 10:04 AM dc0d wrote: > This code compiles and generates no errors. Why? It's legal code according to the language specification. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] ABout the note of slice tricks on Go github wiki

2017-12-12 Thread Jan Mercl
On Tue, Dec 12, 2017 at 3:39 PM T L wrote: > Does it still valid for the latest gc? > In other words, does gc 1.9 still check the segment [len(s), cap[s]) of a slice s to find active pointers? It's not an option, the garbage collector must always scan the whole backing

Re: [go-nuts] Is the result right or not?

2017-12-06 Thread Jan Mercl
On Wed, Dec 6, 2017 at 3:46 PM Jan Mercl <0xj...@gmail.com> wrote: On Wed, Dec 6, 2017 at 3:41 PM T L <tapir@gmail.com> wrote: > It would be helpful if you state where do you see the problem so others do not have to guess. My apologies, you _have_ stated where do you

Re: [go-nuts] Is the result right or not?

2017-12-06 Thread Jan Mercl
On Wed, Dec 6, 2017 at 3:41 PM T L wrote: > ok, I get it. But how about this: It would be helpful if you state where do you see the problem so others do not have to guess. Anyway, the behavior is correct. The loop equals to // initially {3, 5, 7} x[2] = x[0] // {3,

Re: [go-nuts] why fmt "%#v" and "%#q" of string value have different result

2017-12-06 Thread Jan Mercl
On Wed, Dec 6, 2017 at 11:36 AM Ally Dale wrote: > I was confused that why fmt "%#v" and "%#q" of string value have different result. See: https://golang.org/pkg/fmt/#hdr-Printing The default format for %v is: bool:%t int, int8 etc.: %d

Re: [go-nuts] corrupt stack?

2017-12-04 Thread Jan Mercl
On Mon, Dec 4, 2017 at 1:57 PM wrote: > i should have mentioned the race detector found nothing. jan, can you give an example of a go program > setting a pointer to -1 without using unsafe? this requires the gc to have free'd something that is still live, > doesn't it? See

Re: [go-nuts] corrupt stack?

2017-12-04 Thread Jan Mercl
If course it can. On Mon, Dec 4, 2017, 07:46 <quans...@gmail.com> wrote: > a program not using unsafe cannot set a pointer to -1, even if there is a > race, right? > > - erik > > > On Sunday, December 3, 2017 at 10:20:44 PM UTC-8, Jan Mercl wrote: > >>

Re: [go-nuts] corrupt stack?

2017-12-03 Thread Jan Mercl
On Mon, Dec 4, 2017 at 7:03 AM wrote: > does anyone have any idea what's going on here, or some hints on debugging this? What does the race detector say? -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Elphaba Chess

2017-12-02 Thread Jan Mercl
On Sat, Dec 2, 2017, 20:38 wrote: > > Google is not going to be happy if somebody uses Go to compete against > Google. > This is where I stopped considering any of your future posts worth my attention. Disclaimer: I'm not affiliated with Google in any way except

Re: [go-nuts] Sort a huge slice of data around 2GB

2017-11-29 Thread Jan Mercl
On Wed, Nov 29, 2017 at 3:19 PM Subramanian K wrote: > To run 2GB of data it takes really long time, I am trying to split these to buckets and make it run concurrently, finally need to collate results of all these small sorted buckets. Have you measured and detected where

Re: [go-nuts] Reading os.Stdin, Unbuffered

2017-11-27 Thread Jan Mercl
On Mon, Nov 27, 2017 at 4:00 PM dc0d wrote: > Is there a way to read from `os.Stdin` in an unbuffered way? (Not waiting for a `\n` or anything). n, err := os.Stdin.Read(buf) does not wait for `\n`. Or do you actually mean setting a terminal in raw mode?

Re: [go-nuts] Re: Interface value terminology

2017-11-27 Thread Jan Mercl
On Mon, Nov 27, 2017 at 3:18 PM Stefan Nilsson wrote: > I fully understand that this can be implemented in many different ways. That's not my question. Splitting words about "consists of" and "has a" doesn't add much to the discussion. I think the distinction is

<    3   4   5   6   7   8   9   10   11   12   >