Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Jan Mercl
On Fri, Jun 4, 2021 at 3:02 PM christoph...@gmail.com wrote: > > That is true in current implementations, but Go, the language, does not > > guarantee that pointers will never move. > > That is what I thought, but it is allowed to use a pointer far map keys. And > I have seen some

Re: [go-nuts] time.ParseInLocation fails silently

2021-05-28 Thread Jan Mercl
On Fri, May 28, 2021 at 12:32 PM NieomylnieJa wrote: > But the docs state something different: > > // ParseInLocation is like Parse but differs in two important ways. > // First, in the absence of time zone information, Parse interprets a time as > UTC; > // ParseInLocation interprets the time

Re: [go-nuts] Re: Is the escape analysis reports accurate?

2021-06-01 Thread Jan Mercl
On Tue, Jun 1, 2021 at 4:40 PM tapi...@gmail.com wrote: > The following is a tip to get an array pointer but avoid the array escaping. I don't think so. The pointer to the local array 't', stored in 'y' never leaves the function, so there's no need for 't' to escape. See the previous post. > >

Re: [go-nuts] The last line makes the variable y escape. But should it?

2021-06-01 Thread Jan Mercl
On Tue, Jun 1, 2021 at 3:52 PM tapi...@gmail.com wrote: By default, any local variable that has its address taken and that address can outlive the function execution forces the variable to escape, quite naturally as the stack frame with the variable is destroyed upon returning from the function.

Re: [go-nuts] derive encoder/decoder from std json encoder/decoder ?

2021-07-08 Thread Jan Mercl
On Thu, Jul 8, 2021 at 2:30 PM christoph...@gmail.com wrote: > I need to write a binary encoder/decoder very similar to the std JSON > encoder/decoder. > I would like to reuse 80% of the JSON encoder/decoder code and adapt it to > support my binary encoding. > > Is this allowed and at which

Re: [go-nuts] Re: Stack growing is inefficient

2021-07-01 Thread Jan Mercl
On Thu, Jul 1, 2021 at 2:34 PM tapi...@gmail.com wrote: > It is not rare a function will use 10M+ stack. What's the source of this claim? If it's not rare, it should be easy to find an example in the stdlib, I guess. Do you know of one? Note that stacks of such size, if common in the wild,

Re: [go-nuts] Named types vs not named types

2021-06-27 Thread Jan Mercl
On Sun, Jun 27, 2021 at 5:25 PM Victor Giordano wrote: > If you see here you will find a definition for a function. This defines type `HandlerFunc`: https://github.com/golang/go/blob/37f9a8f69d6299783eac8848d87e27eb563500ac/src/net/http/server.go#L2042 > Then if you look here you will find

Re: [go-nuts] UML && Golang, part 2 ?

2021-07-04 Thread Jan Mercl
On Sun, Jul 4, 2021 at 1:16 PM alex-coder wrote: > But what do you use instead then ? For what? In case it's not obvious, I never touched UML and I don't really understand its utility. So I'm asking an honest question. Knowing the answer might help to possibly provide some answer to your

Re: [go-nuts] what is a &^= b means?

2021-04-24 Thread Jan Mercl
On Sat, Apr 24, 2021 at 2:42 PM xie cui wrote: > func f(a, b int) int { > a &^= b > return a > } > what is this op (&^=) means? There is a wonderful source of answers to such questions here: https://golang.org/ref/spec -- You received this message because you are subscribed to the

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Jan Mercl
On Thu, Apr 29, 2021 at 2:26 PM Øyvind Teig wrote: > Your suggestion would in fact do pri select in the special case 1. below: > > Poll highPri first (take it if it's ready), if highPri not ready then take > lowPri (provided highPri has not become ready since the first poll) > However, if

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Jan Mercl
On Thu, Apr 29, 2021 at 3:23 PM Øyvind Teig wrote: > 4c is not "correct" as I want it. In the pri select case, if more than one is > ready, then they shall not be randomly chosen. Never. They should be selected > according to priority. That's not what 4c says. Instead of "more than one ready"

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Jan Mercl
On Thu, Apr 29, 2021 at 3:54 PM Øyvind Teig wrote: > Even if that probability is low, it would need knowledge like yours to show > that this may in fact be zero. There could be a descheduling in between, one > of those in my opinion, not relevant arguments. The upper limit of 4c happening is

Re: [go-nuts] How string constants are propagated inside a small func

2021-04-30 Thread Jan Mercl
On Fri, Apr 30, 2021 at 7:51 PM 'Valentin Deleplace' via golang-nuts wrote: > func f() string { > s := "a" + "b" > return s > } Handled by constant folding. > func g() string { > s := "a" > s += "b" > return s > } The second assignment to 's' here is

Re: [go-nuts] Unexpected pointer dereference behavior

2021-04-22 Thread Jan Mercl
On Thu, Apr 22, 2021 at 1:15 PM Mikhail Mazurskiy wrote: > I stumbled upon this strange looking piece of code [1]. I thought it > dereferences the pointer, creating a copy of the mutex, and then calls > RLock() on the copy (i.e. a nop). But it does not work this way. I > experimented with it

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Jan Mercl
On Thu, Apr 29, 2021 at 10:52 AM Øyvind Teig wrote: > I know from some years ago that go did not have any priority or ordered > select construct [1]. Not sure what does "ordered" wrt select mean, but the default clause of the select statement provides exactly that - a priority mechanism: first

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Jan Mercl
On Thu, Apr 29, 2021 at 11:24 AM Øyvind Teig wrote: > This is not solved with a default clause, which transforms the selective > choice waiting for some event to happen into busy polling. It's nice yo have > some times, but that is something orthogonal to pri/ordered. Not sure if I would call

Re: [go-nuts] tests, init() and flags

2021-04-24 Thread Jan Mercl
On Sat, Apr 24, 2021 at 10:37 PM Shivendra Singh wrote: > ..., now in the init() method it parses flag to read variables such as env > and app name that is required to load the appropriate config. IINM, calling flag.Parse anywhere else than in main() or TestMain() is not really compatible with

Re: [go-nuts] Recursive type definition

2021-05-03 Thread Jan Mercl
On Mon, May 3, 2021 at 6:44 PM Delta Echo wrote: > Hi, Is there any document that explains how recursive type definitions like > > type stateFn func(*Scanner) stateFn > > are handled in Go? Not sure what "handle" means in this case. The language specs do not mention recursive types, so what

Re: [go-nuts] Filtering a type of test in the whole project

2021-02-08 Thread Jan Mercl
On Mon, Feb 8, 2021 at 3:03 PM Johan Martinsson wrote: > Am I missing some option here? It's additionally possible to use a test flag like -mayfail and call flag.Parse() in TestMain(). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] R.I.P. Michael Jones

2021-02-04 Thread Jan Mercl
https://www.geospatialworld.net/blogs/goodbye-michael-jones-the-man-who-gave-the-power-of-maps-in-our-hands/ -- 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: Possible Go 2 proposal for built-in Remove method for Slices.

2021-02-05 Thread Jan Mercl
On Fri, Feb 5, 2021 at 3:46 PM Fernando Meyer wrote: > I understand the pragmatism behind having or not features in the language and > its standard library. But, almost all the golang projects I've worked with > implement their own utility function to remove elements from a slice, > sometimes

Re: [go-nuts] Re: Gidelines or best practices on error on error handling?

2021-01-31 Thread Jan Mercl
On Sun, Jan 31, 2021 at 5:24 PM Amnon wrote: > https://play.golang.org/p/jnRn4Bv98xS > > See the example on the Go Playground. > > Jan, someone can explain to me why it will no longer compile? That's not an example of what I wrote: "Changing it to an unnamed one will cause the program to no

Re: [go-nuts] Re: Gidelines or best practices on error on error handling?

2021-01-31 Thread Jan Mercl
On Sun, Jan 31, 2021 at 6:01 PM Amnon wrote: > If you take the > https://play.golang.org/p/L8z2Q_F_fi3 > > and change the line 18 > from > func foo() (err error) { > > to > func foo() error { > > The code will continue to compile. That's again the case of "making the return variable unnamed and

[go-nuts] Re: [golang-dev] Go 1.16.3 and Go 1.15.11 are released

2021-04-02 Thread Jan Mercl
On Thu, Apr 1, 2021 at 11:52 PM Dmitri Shuralyov wrote: > We have just released Go versions 1.16.3 and 1.15.11, minor point releases. Cleared everything ($ go clean -cache -modcache -testcache ; rm -rf ~/pkg ~/.cache/go-build) and upgraded from 1.15.10 to 1.16.3. Now I am seeing while hacking

Re: [go-nuts] GOOGLE LLC v. ORACLE AMERICA, INC.

2021-04-05 Thread Jan Mercl
On Mon, Apr 5, 2021 at 5:17 PM peterGo wrote: > Held: Google’s copying of the Java SE API, which included only those lines of > code that were needed to allow programmers to put their accrued talents to > work in a new and transformative program, was a fair use of that material as > a matter

Re: [go-nuts] Re: [golang-dev] Go 1.16.3 and Go 1.15.11 are released

2021-04-02 Thread Jan Mercl
On Fri, Apr 2, 2021 at 4:40 PM Michael Pratt wrote: > mgcsweepbuf.go was deleted in 1.16, so it seems you still have files from > 1.15 sitting around in /usr/local/go/. I would swear I've deleted those files, but doing all the steps once again from scratch proves you are right and I can no

Re: [go-nuts] What's the BUG in the flag package?

2021-03-24 Thread Jan Mercl
On Wed, Mar 24, 2021 at 11:25 PM Matt Mueller wrote: > I noticed a lonely BUG comment without an explanation in the flag package: > https://github.com/golang/go/blob/master/src/flag/flag.go#L955 Looking at the code it seems to me that the comment is saying the _client_ code has a bug in that

Re: [go-nuts] Why this global variable assignment is deleted in the infinite loop?

2021-03-11 Thread Jan Mercl
On Thu, Mar 11, 2021 at 6:12 PM WX Lai <0xbill...@gmail.com> wrote: > The code: https://repl.it/talk/share/The-assignment-disappeared/127774 > > The assignment of the global variable `isRunning` in function `fg1` does not > work at all. > In fact, the assignment is deleted in the assembly (see

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 3:53 PM Axel Wagner wrote: > We have different interpretations of "ignore". To me, "ignore" means "be > unaware of or pretend they don't exist". > You seem to use it as "disagree about their validity or the weight they are > given in the decision". That seems

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 4:43 PM 'Axel Wagner' via golang-nuts wrote: > > I don't think it is useful to quibble over the definition of "ignore". When I > said it is demonstrably false that arguments have been ignored, I was > assuming what I perceive to be the common definition: "refuse to take

Re: [go-nuts] Re: go get v git clone

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 3:35 PM arthurwil...@gmail.com wrote: > I just want to remove one thing go getted, not the entire cache. For new features one can fill a proposal. If accepted, a follow-up with the implementation CL is very nice -- You received this message because you are subscribed

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 3:31 PM 'Axel Wagner' via golang-nuts wrote: > I want to re-iterate: The discussion of whether or not generics will be added > to Go has been going on for more than a decade. All arguments from all sides > have gotten fair consideration. A decision was reached. > > You

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 4:18 PM Bruno Albuquerque wrote: > FWIIW, I also agree that "ignore" makes no sense here. You might listen and > think about several opinions/options and conclude that one of them is the > best one. This does not mean you ignored all the others. You do not ignore the

Re: [go-nuts] Re: go get v git clone

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 4:57 PM arthurwil...@gmail.com wrote: > OK I'll try and figure out how to do that. What is a CL? Change List. A patch against the repository that implements a feature, fixes a bug etc. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 1:44 PM Martin Schnabel wrote: > as far as i know there is no reason that anybody has to write code with > generics when they are available. therefor i really don't understand the > negative mails to this list. That nonchalantly ignores that code is way more often read

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Jan Mercl
On Fri, Mar 12, 2021 at 1:24 AM Kevin Chadwick wrote: > Why doesn't go auto init or make an empty map for a named return to avoid the > potential chance of a panic due to operating on a nil return? A non-zero value map value must be allocated. All well-known Go compilers allocate maps in heap.

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 5:52 PM Kevin Chadwick wrote: > Very little resources, unless the map is actually used and not for long. If > you really need to control gos memory use, you need to preallocate arrays in > a long standing manner anyway, not for maps though, as you can't delete >

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-14 Thread Jan Mercl
On Sun, Mar 14, 2021 at 12:57 PM Elias Naur wrote: > > Eg. if you really need to hook at battle-tested C code that needs no > > further maintenance, you may try https://github.com/minio/c2goasm > > It lets you bootstrap fast, then you may aim at a proper rewrite. > > > > A rewrite is one

Re: [go-nuts] Searching recursively in GOLANG

2021-03-16 Thread Jan Mercl
On Tue, Mar 16, 2021 at 7:06 AM Sharan Guhan wrote: > Seems a trivial problem, but unable to find the right imports to do this.. > Want to search for a substring in a huge string ( output of a exec.command) > and get the index for every occurrence of that substring. I used Index and >

Re: [go-nuts] No generic, part -2

2021-03-16 Thread Jan Mercl
On Mon, Mar 15, 2021 at 11:03 PM Ian Lance Taylor wrote: > The formal proposal (https://golang.org/issue/43651) got 1784 thumbs > up and 123 thumbs down (and ten "confused"). Yes, there were critics. > But I think it is fair to say that the proposal has far more > supporters than critics. I

Re: [go-nuts] Why do type aliases change behaviour (i.e. json.Unmarshal)?

2021-03-15 Thread Jan Mercl
On Mon, Mar 15, 2021 at 1:49 PM cpu...@gmail.com wrote: > type WrappedToken Token Note that this is not a type alias. WrappedToken is a new type. Even if its underlying type is Token, WrappedToken does not automatically have any methods of Token. > Only to find out, that unmarshaling a

Re: [go-nuts] Analysis check for leaked pointers to loop variable address

2021-03-15 Thread Jan Mercl
On Mon, Mar 15, 2021 at 3:03 AM Barisere Jonathan wrote: > I think this mistake can be caught by code analysis tools, but I don't know > of any that catches these. IMO the problem is that while sometimes it's a mistake, in some other cases it is not and it is perfectly good, reasonable code.

Re: [go-nuts] Is there a final document on generics?

2021-03-16 Thread Jan Mercl
On Tue, Mar 16, 2021 at 1:10 PM 'Axel Wagner' via golang-nuts wrote: > On Tue, Mar 16, 2021 at 1:05 PM Robert Engels wrote: >> >> Failure to provide a standard “collections” package would be a huge mistake. >> It is certainly a top 3 reason for the success of Java. It would be probably a huge

Re: [go-nuts] How to search standard libarary?

2021-03-16 Thread Jan Mercl
On Tue, Mar 16, 2021 at 4:53 PM jake...@gmail.com wrote: > It seems like a real oversight that there is no search on the official go > documentation though. It seems like it would be really helpful, especially to > beginners. I would love to hear from someone involved why the go team decided

Re: [go-nuts] Re: build world question

2021-03-18 Thread Jan Mercl
On Thu, Mar 18, 2021 at 4:51 PM Brian Candler wrote: > OK. I'll just point out that if the repo contains a set of related packages, > then normally you'd only put a go.mod at the top level. I think the OP never mentioned a repository but "world". I infer that means all the repositories the OP

Re: [go-nuts] now that the election is over can we please remove the political ad for golang.org

2021-03-17 Thread Jan Mercl
On Wed, Mar 17, 2021 at 10:57 AM mortdeus wrote: I'm probably giving up any hopes to work for Google in the future by writing this: +1. I find the banner deeply offensive, divisive and excluding for people with dissenting views, regardless of the omnipresent inclusiveness narrative. I cannot

Re: [go-nuts] How to search standard libarary?

2021-03-17 Thread Jan Mercl
On Wed, Mar 17, 2021 at 4:59 PM jake...@gmail.com wrote: > > On Tuesday, March 16, 2021 at 11:59:31 AM UTC-4 Jan Mercl wrote: >> >> Entering `rename site:golang.org/pkg` in Chrome seems to work well, for >> example. >> >> (But I'm not using this kind of

Re: [go-nuts] about untyped type?

2021-03-19 Thread Jan Mercl
On Fri, Mar 19, 2021 at 1:47 PM xie cui wrote: > https://github.com/golang/go/blob/master/src/cmd/compile/internal/types2/universe.go#L58-L64 > there are some basic type call untyped xxx? what is it mean? Untyped bool, int, etc are the types of untyped constants:

Re: [go-nuts] Some questions about the memory allocation strategy of channel

2021-03-19 Thread Jan Mercl
On Fri, Mar 19, 2021 at 4:36 AM Paul Zhang wrote: Please do not post colorized code to the ML. Particularly with inverted colors. Please use plain black on white text, thank you. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] About the efficency of modifying map elements.

2021-03-17 Thread Jan Mercl
On Wed, Mar 17, 2021 at 9:18 PM tapi...@gmail.com wrote: > Now, to modify a map element, especially the element type is not a basic > type, two hashes are needed to compute. https://github.com/golang/go/issues/5147 -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Supporting contained zip archives inside of tar and zip archives

2021-03-17 Thread Jan Mercl
On Wed, Mar 17, 2021 at 7:38 PM Glen Newton wrote: > > zip archives contain files and directories. Often, some of the files > contained in zip archives are also archives, zip and tar(.gz|bz2). Sometimes, > these contained archives also contain such archives (and so on...). > > Reading a zip

Re: [go-nuts] Contrary to popular opinion...

2021-02-27 Thread Jan Mercl
On Sat, Feb 27, 2021 at 10:37 PM Bob Alexander wrote: > Try removing all the space from your post and see how understandable it is, > or remove all indentation from a Go program, etc. (Hmm, that would make > formatters a lot easier to write... ) Removing all spaces makes most languages

Re: [go-nuts] Golang Problems

2021-02-27 Thread Jan Mercl
On Sun, Feb 28, 2021 at 6:32 AM Marcin Romaszewicz wrote: > - if s is a string, s[0] is a rune If s is a non-empty string, s[0] is a byte. > - if r is a rune, string(r) is a 1 character string If r is a rune, string(r) is a string of 1 or more bytes. -- You received this message because you

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Jan Mercl
On Sun, Feb 28, 2021 at 9:05 AM 'Dan Kortschak' via golang-nuts wrote: > I'm curious where the meaningful whitespace is in Go (for amounts > differences in number greater than 1). I meant, for example, in regexp notation, ` *` vs `\n *` between a function signature and the opening brace of the

Re: [go-nuts] `for i, v := range` causes allocation

2021-04-12 Thread Jan Mercl
On Mon, Apr 12, 2021 at 6:01 PM Luke Wilson wrote: > I've heard several times from members of the community (on Matrix and > possibly on answers) that a simple iteration like > > const mixed = "\b5Ὂg̀9! ℃ᾭG" > for _, c := range mixed { > ... do something with c (but not write to it) > > will

Re: [go-nuts] Why can I not install external packages?

2021-04-13 Thread Jan Mercl
On Tue, Apr 13, 2021 at 11:40 AM Tenjin wrote: > So I am using WSL2 to develop using golang but for some reason I am unable to > use other peoples packages. > For example: I am wanting to use the sql driver > https://github.com/go-sql-driver/mysql I am able to go get it and it says it > is

Re: [go-nuts] Go Semantics Aware diff tool?

2021-04-14 Thread Jan Mercl
On Wed, Apr 14, 2021 at 1:51 PM Steve Mynott wrote: > I'm aware tools exist to parse go and a quick google search search > fails me but I was wondering if there was a utility which was a > go-aware diff which I could use like "git diff master" which printed > out a list of funcs changed? Would

Re: [go-nuts] What is the easiest way to find out the source hosting url of a thrid-party dependency module/package?

2021-04-08 Thread Jan Mercl
On Thu, Apr 8, 2021 at 5:18 PM tapi...@gmail.com wrote: > It looks such info is not recorded in GOPATH/pkg/mod. Do you mean the import path to repository URL mapping? jnml@e5-1650:~/tmp$ wget modernc.org/sqlite && grep go- sqlite --2021-04-08 17:23:49-- http://modernc.org/sqlite Resolving

Re: [go-nuts] big.Float.Cmp does not work as expected

2021-02-16 Thread Jan Mercl
On Tue, Feb 16, 2021 at 9:30 PM Santhosh T wrote: > in Java, this is not case. That compares decimal vs floating point representations. Those have very different properties, for different usage patterns. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Re: SQLite3 Support without CGo

2021-02-17 Thread Jan Mercl
On Tue, Feb 16, 2021 at 10:52 PM ben...@gmail.com wrote: > Jan, is there any write-up about modernc.org/sqlite? I've dabbled in > automated conversion, and I'm very curious if there's more information about > how it works, any pitfalls / unsupported stuff, etc, but having trouble > finding

Re: [go-nuts] Re: Possible Go 2 proposal for built-in Remove method for Slices.

2021-02-06 Thread Jan Mercl
On Sat, Feb 6, 2021 at 5:36 PM Sean wrote: > I think there is definitely a need for a built-in "remove" function for > arrays and slice. > Everyone is writing their own implementation for this, it is both confusing > and "x = append(a[:x], b[x:])" like blablabla is not readable. Please define

Re: [go-nuts] Re: Possible Go 2 proposal for built-in Remove method for Slices.

2021-02-06 Thread Jan Mercl
On Sat, Feb 6, 2021 at 8:01 PM Axel Wagner wrote: > FTR, I think even a library function that is defined as "the equivalent of > `append(a[:i], a[j:]...)`" (for example) would provide value. Yes, but IMO a net negative value. Many people will then mindlessly just use this O(n) variant even

Re: [go-nuts] gofmt return multiple function closures

2021-02-19 Thread Jan Mercl
On Fri, Feb 19, 2021 at 3:46 PM Neehar Vijay wrote: > Is this intentional? Does gofmt assume tab width of 4 or 8? No. Does this look better? https://play.golang.org/p/0NnZmegKVAu Ie. just add a line break between the return values. Gofmt will keep yout choice. -- You received this message

Re: [go-nuts] Is there a preview Golang version I can download to try out generics ?

2021-08-22 Thread Jan Mercl
On Sun, Aug 22, 2021 at 7:50 PM Serge Hulne wrote: > Is there a preview Golang version I can download to try out generics ? Use this doc: https://golang.org/doc/install/source And follow this optional step: https://golang.org/doc/install/source#head Not tested. -- You received this message

Re: [go-nuts] Function to escape and unscape string

2021-08-29 Thread Jan Mercl
On Sun, Aug 29, 2021 at 9:02 PM 'nadashin' via golang-nuts wrote: > fmt.Printf has a format specifier, %q that escapes string with Go > syntax and add quotes around the string. ( %#v also does it) > > But it doesn't have one that unescapes a string. > > I couldn't find any stdlib function that

Re: [go-nuts] Whats wrong with my channel

2021-08-19 Thread Jan Mercl
On Thu, Aug 19, 2021 at 4:43 PM Денис Мухортов wrote: > I just started practicing with channels, after writing to the channel, > nothing is output from there > func main() { > d := make(chan int) > go factorial(5, d) > time.Sleep(3 * time.Second) > } > > func factorial(n int, d

Re: [go-nuts] strings: escape sequence translation

2021-09-07 Thread Jan Mercl
On Tue, Sep 7, 2021 at 4:40 AM 'nadashin' via golang-nuts wrote: > Why is the function in Go compiler that interprets escape sequences not > available in Go's standard library? FTR: This seems to be an unfortunate way of continuing the thread at

Re: [go-nuts] strings: escape sequence translation

2021-09-07 Thread Jan Mercl
On Tue, Sep 7, 2021 at 2:29 PM 'nadashin' via golang-nuts wrote: > > It does. See https://pkg.go.dev/strconv#Unquote. Try this hastily thrown > > together example: > > > > package main > > > > import ( > > "fmt" > > "strconv" > > ) > > > > func main() { > > e :=

Re: [go-nuts] Various questions about posts from The Go Blog

2021-09-07 Thread Jan Mercl
On Tue, Sep 7, 2021 at 12:40 PM Kamil Ziemian wrote: > In the post "Concurrency is not parallelism" by Andrew Gerrand > (https://go.dev/blog/waza-talk) under the paragraph starting with "To clear > up this conflation, Rob Pike gave a talk at Heroku’s Waza" in my browser is > big blank space.

[go-nuts] exec.CommandContext questions

2021-10-12 Thread Jan Mercl
modernc.org/ccgo/v3 compiles test C source files into Go source file and executes the result to check if it compiles and performs correctly. To avoid incorrectly transpilled programs to hang the test, the resulting Go code is executed like this: out, err := func() ([]byte, error) {

Re: [go-nuts] Re: exec.CommandContext questions

2021-10-12 Thread Jan Mercl
On Tue, Oct 12, 2021 at 4:35 PM Brian Candler wrote: > I think that's it. New version of main.go: > https://play.golang.org/p/KpvwsJtwHyQ > > It stops after 1 second in each case. Wonderful! Thank you very much. I hope to have permission to use your code, do I? I suggest sending a PR that adds

Re: [go-nuts] Re: exec.CommandContext questions

2021-10-12 Thread Jan Mercl
On Tue, Oct 12, 2021 at 4:56 PM Brian Candler wrote: > You're more than welcome to use it - it's nothing more than a snippet that > reimplements one line of cmd.Start. > > Actually, checking that source code: at your side you should call > exec.Command not exec.CommandContext. That is: > >

Re: [go-nuts] Re: cgo keep consuming memory for SysStack until OOM

2021-10-06 Thread Jan Mercl
On Wed, Oct 6, 2021 at 5:43 PM Renat Idrisov wrote: > Total allocations of golang program are about 42MB, but go runtime takes 8GB > for in OS thread stacks. > What am I doing wrong? If you're on 64 bit Linux, chances are the default OS thread stack size is 8 MB. In that case your program uses

Re: [go-nuts] Re: cgo keep consuming memory for SysStack until OOM

2021-10-06 Thread Jan Mercl
On Wed, 6 Oct 2021, 18:38 Renat Idrisov, wrote: ... I do use a lots of gorotines, > but I supposed they are not mapped to OS threads that frequently. > The runtime attempts to limit the number of OS threads to the value of GOMAXPROCS. However, some threads do not count against that budget,

[go-nuts] IEEE rounding question

2021-10-05 Thread Jan Mercl
This is a variation on https://github.com/gcc-mirror/gcc/blob/2f2aeda98f3aa24034a700e7efcb6c1a9397836f/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.c package main /* float s(unsigned long long k) { float x; x = (float)k; return x; } unsigned long long cmain() {

Re: [go-nuts] IEEE rounding question

2021-10-06 Thread Jan Mercl
On Wed, Oct 6, 2021 at 1:06 AM Ian Lance Taylor wrote: > I opened https://golang.org/issue/48807. Thank you. -- 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] Why Doesn't "len()" Work With Structs?

2021-10-24 Thread Jan Mercl
On Sun, Oct 24, 2021 at 8:11 PM jlfo...@berkeley.edu wrote: > I noticed that the len() function doesn't take a struct as an argument (see > below). > This is a big surprise. Can someone shed some light on why this restriction > exists? What is the expected value of len() when applied to a

Re: [go-nuts] Re: Go 1.18 Beta 1 is released

2021-12-17 Thread Jan Mercl
On Fri, Dec 17, 2021 at 6:28 AM Ian Lance Taylor wrote: > There are no compatibility promises for unsupported techniques like > go:linkname. If they update their copy of golang.org/x/sys, it will > work with Go1.18beta1. I believe that this was fixed by > https://golang.org/cl/274573 which was

Re: [go-nuts] Two Questions About Maps

2021-12-19 Thread Jan Mercl
On Sun, Dec 19, 2021 at 6:03 PM jlfo...@berkeley.edu wrote: > 1) Let's say I wanted to make the map elements smaller, so the map value > would be a pointer to a structure, not the structure itself. I couldn't > figure out how to modify this program so that the initialization still > worked.

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread Jan Mercl
On Wed, Jan 5, 2022 at 11:09 AM Brieuc Jeunhomme wrote: > But here ,since under non-windows platforms, I can't import the package, it > means I have to define wrappers for everything I use: types, constants, > functions. I don't get it. Put the common code in a file/in files with no build

Re: [go-nuts] unit testing OS specific code

2022-01-05 Thread Jan Mercl
On Wed, Jan 5, 2022 at 11:32 AM Brieuc Jeunhomme wrote: > > So: > $ cat mypackage.go > package mypackage > > import "something/something/foo" > > func MyFunction() { > some code > some code > some code > foo.Bar(make(chan foo.Baz), make(chan foo.Foobar)) > } > > Is the code I would

Re: [go-nuts] Command `go test` without build constraints does not work

2022-01-03 Thread Jan Mercl
On Mon, Jan 3, 2022 at 9:48 PM Davi Marcondes Moreira wrote: > I've read the docs for https://pkg.go.dev/go/build and > https://pkg.go.dev/cmd/go#hdr-Build_constraints but I couldn't find anything > explicitly related to test execution. It is not related to test execution. The build system

Re: [go-nuts] Re: New site go.dev is awful

2021-11-24 Thread Jan Mercl
On Wed, Nov 24, 2021 at 10:53 PM ben...@gmail.com wrote: > 2) The download link is for the Windows binary, and I'm running Linux. [image: image.png] -- 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] Re: compile time error vs runtime crash for same array

2021-11-25 Thread Jan Mercl
The linker knows nothing about heap. That's a runtime only thing. On Fri, Nov 26, 2021, 05:00 arthurwil...@gmail.com < arthurwilliammor...@gmail.com> wrote: > > On Saturday, November 13, 2021 at 12:48:41 PM UTC-6 seank...@gmail.com > wrote: > >> global variables are stored in there data section

Re: [go-nuts] Amateur question: when you should use runes?

2021-11-18 Thread Jan Mercl
On Mon, Nov 15, 2021 at 7:00 PM Kamil Ziemian wrote: > ... when in practice you should use runes? For example the API of the unicode package uses runes extensively: https://pkg.go.dev/unicode. > My understanding at this moment is like that. Unicode assign every symbol a > number (at this

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2021-10-29 Thread Jan Mercl
On Fri, Oct 29, 2021 at 12:53 PM Kamil Ziemian wrote: > > From what I understand about EBNF production_name should be defined using > EBNF notation in manner like below. > > production_name = something1 | something2 > > But I don't see such definition in Spec. Because production_name is a

Re: [go-nuts] initialization loop ?

2021-10-22 Thread Jan Mercl
testSlice mentions printLen, printLen mentions testSlice. The specification explicitly forbids such init cycles. On Fri, 22 Oct 2021, 19:51 dana...@gmail.com, wrote: > Why do I get an initialization loop in the following program? > > ```go > package main > import "fmt" > var testSlice =

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2021-11-07 Thread Jan Mercl
On Sun, Nov 7, 2021 at 7:23 PM Kamil Ziemian wrote: > Can anyone give me explicit example when semicolon is omitted in accordance > to the second rule and explanation where it should be? I probably see such > situations dozens of times, I just not know that they would needed semicolon > in

Re: [go-nuts] How to force cgo to use C++ compiler (g++) instead of gcc ?

2021-10-31 Thread Jan Mercl
On Sun, Oct 31, 2021 at 6:17 PM Elemer Pixard wrote: > Is there a way to solve this ? Some hopefully related info can be found here: http://www.swig.org/Doc3.0/Go.html -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] question about stdin

2021-12-12 Thread Jan Mercl
On Sun, Dec 12, 2021 at 5:15 PM Денис Мухортов wrote: > It's a little unclear how os.stdin actually works. Why, if you just run the > program, is data from stdin constantly being listened to? > For example: > func main() { > sc := bufio.NewScanner(os.Stdin) > for sc.Scan() { >

[go-nuts] Re: Go 1.18 Beta 1 is released

2021-12-16 Thread Jan Mercl
On Tue, Dec 14, 2021 at 8:51 PM Cherry Mui wrote: There's a test regression with Go1.18beta1 on freebsd/amd64 and modernc.org/file. The log file (https://gitlab.com/cznic/builder/-/blob/cdca564a0543e9ad0441884e3c12f7c0a326bdab/logs/freebsd64) does not say much and I have not yet managed to

[go-nuts] Re: Go 1.18 Beta 1 is released

2021-12-16 Thread Jan Mercl
On Tue, Dec 14, 2021 at 8:51 PM Cherry Mui wrote: Let me report another failure that works, ie. tests build and pass, with Go1.17.5 but not with Go1.18beta1 jnml@darwin-m1:~$ GO111MODULE=off go get github.com/edsrzf/mmap-go jnml@darwin-m1:~$ cd edsrzf/mmap-go/

Re: [go-nuts] nil

2021-12-02 Thread Jan Mercl
On Thu, Dec 2, 2021 at 10:13 AM Денис Мухортов wrote: > How can the output of the program be explained? Why checking for nil gives > false?? Because it is not nil: https://go.dev/doc/faq#nil_error -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: Go 1.18 Beta 1 is released

2021-12-15 Thread Jan Mercl
On Tue, Dec 14, 2021 at 8:51 PM Cherry Mui wrote: > We have just released go1.18beta1, a beta version of Go 1.18. > It is cut from the master branch at the revision tagged go1.18beta1. > > Please try your production load tests and unit tests with the new version. > Your help testing these

Re: [go-nuts] Re: Go 1.18 Beta 1 is released

2021-12-15 Thread Jan Mercl
On Wed, Dec 15, 2021 at 7:41 PM Austin Clements wrote: > Jan, assuming you're running on an AMD CPU, this is go.dev/issue/34988 (if > you're not running on an AMD CPU, that would be very interesting to know!) > The TL;DR is that this appears to be a kernel bug, and we have a C > reproducer,

Re: [go-nuts] Strange cases of type definitions that use "[]", Go 1.17 and 1.18beta2

2022-02-11 Thread Jan Mercl
On Fri, Feb 11, 2022 at 5:06 PM 'Axel Wagner' via golang-nuts wrote: > FYI I went ahead and filed https://github.com/golang/go/issues/51145 I must be missing something because I still don't understand what the problem is. The syntax `type A[B]C` can be reduced both in Go1.17 and Go1.18 in only

Re: [go-nuts] Pointer to a pointer

2022-03-15 Thread Jan Mercl
On Tue, Mar 15, 2022 at 4:41 PM Thomas Bushnell BSG wrote: > Not in the normal implementation it doesn't. Typically it might be: > > type element struct { > value int > next *element > } > > next is a pointer to an element, not a pointer to a pointer. That element > contains within it a

Re: [go-nuts] Pointer to a pointer

2022-03-09 Thread Jan Mercl
A linked list, for example, consists of pointers to pointers to pointers... Why should any limit exist to the length of the list except resources available? On Thu, Mar 10, 2022, 03:59 shan...@gmail.com wrote: > This morning someone asked about dereferincing a pointer to a pointer to a >

Re: [go-nuts] Pointer to a pointer

2022-03-10 Thread Jan Mercl
On Thu, Mar 10, 2022 at 1:40 PM 'wagner riffel' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I don't think it's mentioned in the specification, my bet is that > unless your type requires inifnity amout of memory (eg: `type t struct > {t}`) or the type is an interface and break its

Re: [go-nuts] Pointer to a pointer

2022-03-10 Thread Jan Mercl
On Thu, Mar 10, 2022 at 2:18 PM 'Axel Wagner' via golang-nuts wrote: > TBH I find it rather surprising that the spec does not mention why `type X X` > is *not* allowed. The specs guarantee unsafe.Sizeof() to produce the size. I think that gives a Go compiler the right to reject that type

<    5   6   7   8   9   10   11   12   >