Re: [go-nuts] evaluation of range expression in for-range loop

2022-03-18 Thread Jan Mercl
On Fri, Mar 18, 2022 at 12:43 PM Jochen Voss wrote: > The spec at https://go.dev/ref/spec#For_range says > > "The range expression x is evaluated once before beginning the loop, with one > exception: if at most one iteration variable is present and len(x) is > constant, the range expression is

Re: [go-nuts] What goes wrong when embedding goroutines inside a for loop?

2022-02-17 Thread Jan Mercl
On Thu, Feb 17, 2022 at 5:44 PM Zhaoxun Yan wrote: This goes wrong: jnml@3900x:~/tmp$ cat main.go package main import "fmt" func main() { targetIndice := make([]int, 3) targetIndice[0] = 5 targetIndice[2] = 4

Re: [go-nuts] feedback from my first experiment with generic go code

2022-02-16 Thread Jan Mercl
On Wed, Feb 16, 2022 at 5:31 PM Jochen Voss wrote: > To me it is not intuitive why "comparable" is built intro the language but > "Ordered" is in an external package. Quoting rogpepe from elsewhere: because there's no way to define comparable as a type constraint, but you can do that

Re: [go-nuts] Is it safe to say two unname interface types are identical if their type sets are identicial?

2022-03-24 Thread Jan Mercl
On Thu, Mar 24, 2022 at 1:56 PM 'Axel Wagner' via golang-nuts wrote: > I believe you are correct in that the spec needs work here. The two should > probably not be considered identical, but they are according to the spec > right now. > I'm not sure this poses an immediate problem, as I don't

Re: [go-nuts] Is it safe to say two unname interface types are identical if their type sets are identicial?

2022-03-24 Thread Jan Mercl
On Thu, Mar 24, 2022 at 11:58 AM tapi...@gmail.com wrote: https://go.dev/ref/spec#Type_identity Two interface types are identical if they define the same type set. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] How to contribute to /x/ ?

2022-03-31 Thread Jan Mercl
On Thu, Mar 31, 2022 at 8:42 PM Jen Zarzycki wrote: > I'd like to submit an implementation of sync.Map (using generics) to the > golang.org/x/sync repo. If you want to propose an API change, please start by submitting a proposal here: https://github.com/golang/go/issues, thanks. -- You

Re: [go-nuts] Re: autoremove unviolated precondition checks at compile time

2022-03-30 Thread Jan Mercl
On Thu, Mar 31, 2022 at 5:27 AM Henry wrote: > // +build debug > > package mypkg > > func init() { >Debug = true > } Doing here instead const Debug = true removes (DCE) the runtime checks in other files. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Re: autoremove unviolated precondition checks at compile time

2022-03-31 Thread Jan Mercl
On Thu, Mar 31, 2022 at 10:01 AM Toon Knapen wrote: > but that would enable or disable _all_ precondition checks. Sure, that's the point. Henry used the +build debug mechanism, so the checks would be disabled in production. If one wants the checks to be always present there's no need to use a

Re: [go-nuts] Type Hints for Golang

2022-04-01 Thread Jan Mercl
On Fri, Apr 1, 2022 at 5:08 PM Amnon wrote: > Python has had Type Hints since 2014 (see PEP 484). 60 seconds! -- 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] Need help

2022-02-02 Thread Jan Mercl
On Wed, Feb 2, 2022 at 2:14 PM Shaown Abir wrote: > I am new to golang. The name of the programming language is Go. > Here is the problem in my code. I don't know how to solve it. I thought my > code is ok but it shows an error. Can anybody tell me the solution of my > code? Thank you.

Re: [go-nuts] generic function with a pointer parameter

2022-01-27 Thread Jan Mercl
On Thu, Jan 27, 2022 at 11:42 AM Manlio Perillo wrote: > What is the reason why the code does not compile? I cannot answer your question, but just noting that this compiles and executes fine: https://gotipplay.golang.org/p/wveI2JzIxSr -- You received this message because you are subscribed to

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 12:50 PM Kamil Ziemian wrote: > I need to go for a while, I will go back with more questions about what you > can get when using "[]" in Go. The '[' and ']' is just a pair of tokens with no meaning attached to it per se. Context is everything. So square brackets in one

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 3:13 PM Kamil Ziemian wrote: > "> type someDifferentInt[float64] int > I can't see why the parser can't see that this should (if anything) be > interpreted as an array type declaration. To me, this seems like a > regression. I'd suggest maybe filing an issue." > > I

Re: [go-nuts] Game Of Life in Go : Any comments welcome (I'm not sure I have implemented it correctly)

2022-04-09 Thread Jan Mercl
One more variant at https://www.reddit.com/r/golang/comments/14s59i/conways_game_of_life_by_jan_mercl/ ;-) On Sat, Apr 9, 2022, 17:39 Serge Hulne wrote: > I have just published on Github one possible implementation of Conway's > Game of Life in Go: > >

Re: [go-nuts] io.WriteString to a file panics

2022-04-12 Thread Jan Mercl
On Tue, Apr 12, 2022 at 9:53 AM Rory Campbell-Lange wrote: > Attempting to write to a named file panics on go 1.17 on Linux with: > > panic: runtime error: invalid memory address or nil pointer dereference > [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x46123d] Not

Re: [go-nuts] How ignore a subdirectory

2023-09-13 Thread Jan Mercl
On Wed, Sep 13, 2023 at 5:47 AM 'John Souvestre' via golang-nuts wrote: > I’m trying to run gofmt on all of the .go files in a directory, but not any > subdirectories. $ gofmt *.go -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] How ignore a subdirectory

2023-09-13 Thread Jan Mercl
On Wed, Sep 13, 2023 at 12:25 PM John Souvestre wrote: > I did try that also. I get this error message: > > CreateFile *.go: The filename, directory name, or volume label syntax is incorrect. Sorry, I'm not familiar with Windows and only TIL cmd.exe does not expand globs. I suggest to

Re: [go-nuts] Re: Weird error when trying to fetch a module.

2023-09-15 Thread Jan Mercl
On Fri, Sep 15, 2023 at 10:31 AM 'Jim Idle' via golang-nuts < golang-nuts@googlegroups.com> wrote: > The go.mod at the root was one thing that might work, but it will cause the entire repo to be pulled in so the tag will still have to be sec/go/ etc. tl;dr: Putting a go.mod in the repository

Re: [go-nuts] How to constrain an integral type's values

2023-09-08 Thread Jan Mercl
On Fri, Sep 8, 2023 at 9:24 AM 'Mark' via golang-nuts wrote: > Is there a compile-time solution for this that I've missed? No. Go does not have enum types. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Re: Why causes []any trouble in type equations?

2023-10-11 Thread Jan Mercl
On Wed, Oct 11, 2023 at 8:11 PM Torsten Bronger wrote: > Then, all boils down to the fact that you can’t pass []float64 as an > []any. To be honest, I still don’t fully understand why this is > forbidden, so I just accept that the language does not allow it. It's the same reason why one cannot

Re: [go-nuts] Help understanding slices, variable arguments, and passing slices to functions

2023-09-25 Thread Jan Mercl
On Mon, Sep 25, 2023 at 1:57 PM Andrew Pillar wrote: A nice discussion of slices can be found for example here: https://research.swtch.com/godata tl;dr: Yes, slices are passed by value (everything in Go is passed by value), but a slice does not contain the backing array, only a pointer to it.

Re: [go-nuts] The docs for secretbox seem very wrong

2023-10-09 Thread Jan Mercl
On Mon, Oct 9, 2023 at 3:46 PM Dean Schulze wrote: > If the docs are correct, how do you append to nil? https://go.dev/play/p/WY0Bycj-_Tn -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] how do you compie and link a go main with an assembly code file?

2023-10-09 Thread Jan Mercl
On Mon, Oct 9, 2023 at 6:02 PM Peter Riemenschneider wrote: Just '$ go build' as usual, but one must declare the asm function: https://go.dev/play/p/KySqFvCVz_T -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Best IDE for GO ?

2023-08-19 Thread Jan Mercl
On Sat, Aug 19, 2023 at 9:42 PM Robert Engels wrote: > I guarantee that two developers of equal competence - the one with a powerful > IDE will outperform the other using a text editor with syntax highlighting > (but come on that is a crutch a real developer doesn’t need) by 2-10x > depending

Re: [go-nuts] Best IDE for GO ?

2023-08-19 Thread Jan Mercl
On Sat, Aug 19, 2023 at 10:06 PM Christian Stewart wrote: > Autocomplete and a go language server (gopls) add a ton of speed because you > don't need to look up the docs for function and variable names. And go to > definition improves speed navigating code significantly. - Using autocomplete

Re: [go-nuts] Best IDE for GO ?

2023-08-19 Thread Jan Mercl
On Sat, Aug 19, 2023 at 11:27 AM alex-coder wrote: > Gophers, may be there is another place where I should look for IDE for GO ? Unix is my IDE and vim is its prophet. IME IDEs make programmers write low quality code while enjoying the illusion of being "more productive". -- You received

Re: [go-nuts] Re: Best IDE for GO ?

2023-08-26 Thread Jan Mercl
On Sat, Aug 26, 2023 at 2:33 PM Jason E. Aten wrote: > > Is there any IDE that allows you to jump through a stack trace like emacs > does? I think many code editors can do that, for example vim: https://vim.fandom.com/wiki/Open_file_under_cursor -- You received this message because you are

Re: [go-nuts] evaluation of range expression in for-range loop

2022-03-18 Thread Jan Mercl
On Fri, Mar 18, 2022 at 4:53 PM 'Axel Wagner' via golang-nuts wrote: > > One thing to keep in mind is that Go development was incremental and was > done, from early on, by having multiple implementations. Incremental > processes often lead to different results than designing a language from a

Re: [go-nuts] ldflags -X

2023-11-08 Thread Jan Mercl
On Wed, Nov 8, 2023 at 4:01 PM Stephen Illingworth wrote: > I would have expected the "main.A" string to require the same form. But > either way, that's the correct solution. It is the correct form. Package main cannot be imported and has a special import path. Though I don't know where it is

Re: [go-nuts] ldflags -X

2023-11-08 Thread Jan Mercl
On Wed, Nov 8, 2023 at 1:35 PM Stephen Illingworth < stephen.illingwo...@gmail.com> wrote: > > Hello, > > I'm trying to use the -X ldflag to set a string at compile time. I can do this successfully if the string is in the main package but it does not work if the string is in a subpackage. > > For

[go-nuts] Possible minor specification issues

2022-05-20 Thread Jan Mercl
I think there might be two small omissions in the EBNF grammar for Go 1.18: LiteralType = StructType | ArrayType | "[" "..." "]" ElementType | SliceType | MapType | TypeName . EmbeddedField = [ "*" ] TypeName . It seems to me that in both productions s/TypeName/TypeName [

Re: [go-nuts] Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread Jan Mercl
On Thu, Jun 2, 2022 at 4:38 PM Deividas Petraitis wrote: > 1. Structs are for representing things, they are things Forget about structs. Methods are attached to types. Structs are just one of the many kinds of types. Assuming structs only does not provide the full picture one needs to think

[go-nuts] Fwd: Possible minor specification issues

2022-05-30 Thread Jan Mercl
Gentle ping after no feedback. FTR: The proposed change was tested by an ad-hoc PEG interpreter based on the updated EBNF: https://gitlab.com/cznic/gc/-/blob/6cc7f3006a019a52c49db3d13276c0a5c6d24a00/v2/internal/ebnf/all_test.go#L275. -- Forwarded message - From: Jan Mercl <

Re: [go-nuts] How Unbuffered channel work

2022-06-05 Thread Jan Mercl
On Sun, Jun 5, 2022 at 4:06 PM Manjeet S wrote: > Can someone help me to understand why this code is not working. I'm expecting > that <-ch wait until we receive from channel ch The range statement at line 18 does not complete unless the channel is closed. Adding `close(ch2)` at line 14 fixes

Re: [go-nuts] Are pointers guaranteed to keep the entire pointee alive?

2022-05-07 Thread Jan Mercl
On Sat, May 7, 2022 at 2:53 PM Axel Wagner wrote: >> AFAICT, interior pointers do and must keep the entire allocation block >> alive, > > Is there any "official" documentation on the "must"? I don't think there is and I don't think it's necessary. I believe it's implied by the language

Re: [go-nuts] Are pointers guaranteed to keep the entire pointee alive?

2022-05-07 Thread Jan Mercl
On Sat, May 7, 2022 at 12:34 PM 'Axel Wagner' via golang-nuts wrote: > I am assuming this is true, but I couldn't find a definitive answer yet (or > rather, the answers seems bad): Does a pointer into any part of a value keep > the entire value alive? So, e.g. is this code safe? > > type A

Re: [go-nuts] Which is the most efficient way to read STDIN lines 100s of MB long and tens of MB info is passed to it

2022-05-07 Thread Jan Mercl
On Sat, May 7, 2022 at 10:24 PM Constantine Vassilev wrote: > I need to write a program that reads STDIN and should output every line that > contains a search word "test" to STDOUT. Piping the data through grep(1) would be my first option. -- You received this message because you are

Re: [go-nuts] Add comparisons to all types

2022-05-03 Thread Jan Mercl
On Tue, May 3, 2022 at 8:32 AM Will Faught wrote: > Just as pointer comparisons are shallow, so too are comparisons for types > that contain pointers. Pointer comparisons are not shallow. Comparing two pointers compares the entire values. a == b and *a == *b compare different values but in

Re: [go-nuts] Add comparisons to all types

2022-05-04 Thread Jan Mercl
On Wed, May 4, 2022 at 4:27 AM Ian Lance Taylor wrote: > In saying this I don't at all claim that Go is perfect. There are > places where we made mistakes. May I please ask you to share what you personally consider a mistake and, if possible, what would you change if you can, say, travel back

Re: [go-nuts] Add comparisons to all types

2022-05-04 Thread Jan Mercl
On Wed, May 4, 2022 at 12:15 AM Will Faught wrote: > I'm not sure we're on the same page in terminology. I meant shallow as > opposed to deep. E.g. pointer equality in terms of `==` vs. > `reflect.DeepEqual`. Unequal pointers can reference values that are > equivalent. I think we are on the

Re: [go-nuts] Add comparisons to all types

2022-05-05 Thread Jan Mercl
On Wed, May 4, 2022 at 10:10 PM Ian Lance Taylor wrote: > I can only give some personal opinions. Others will disagree. And my > opinions change over time, and could well be mistaken. > > I think that deciding that := declares a single variable in a > for/range statement was a mistake

Re: [go-nuts] Golang Deadlock

2022-08-23 Thread Jan Mercl
On Tue, Aug 23, 2022 at 8:40 PM Nihan Khan wrote: > How golang runtime detect deadlock internally? I haven't checked the runtime sources about this, but my guess is something like is done when the scheduler looks for something to do: 'if numberOfGoroutinesBlocked() != 0 &&

Re: [go-nuts] Re: Go 1.19 average goroutine stack

2022-08-18 Thread Jan Mercl
On Thu, Aug 18, 2022 at 10:34 AM T L wrote: > When I investigate something, I ask questions in communities firstly, to save > time. To save your time at the expense of more time wasted by others. Such an approach is rightfully frowned upon. Doing your own research first, asking about things

Re: [go-nuts] How long does it take to import packages?

2022-08-31 Thread Jan Mercl
On Wed, Aug 31, 2022 at 9:00 AM ag9920 wrote: > Hi, recently I've been trying to make my unit test faster. It seems too much > time were spent on initialization. The "seems" part is a guess or a measurement? How much is "too much time"? > After removing all init() function in relevant

Re: [go-nuts] a function returning a function of type int

2022-08-24 Thread Jan Mercl
On Wed, Aug 24, 2022 at 7:23 AM Rino Mardo wrote: Example of a function returning a function: https://go.dev/play/p/9FY0GDhKJNd -- 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,

Re: [go-nuts] Occasional hard lockup w/ 100% CPU usage in go applications

2022-10-26 Thread Jan Mercl
On Wed, Oct 26, 2022 at 3:28 PM Steven Sokol wrote: > Currently running go 1.9.1, but I've been having this same issue since I > started working on this project about two years ago on 1.5.x. That version is 5 years old: https://go.dev/doc/devel/release#go1.9 Can you try a recent, supported

Re: [go-nuts] Integration testing program that internally forks itself

2022-10-27 Thread Jan Mercl
Any recursion that does not have a terminating condition will try to recurse infinitely ;-) I'm passing a command line flag in such situations - when testing, but the best option depends on the particular use. Elsewhere, in a command that starts a server or talks to the server, I used, for

Re: [go-nuts] Re: Using golang variable in bash script Command

2022-09-19 Thread Jan Mercl
On Mon, Sep 19, 2022 at 2:52 PM Amnon wrote: > What happens if the user enters the string "'; rm -fr ~;'" ? https://twitter.com/codepo8/status/1373224835866882048 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] Using golang variable in bash script Command

2022-09-19 Thread Jan Mercl
On Mon, Sep 19, 2022 at 11:50 AM PK wrote: > search:=scanner.Text() > cmd1,err:=exec.Command("bash", "-c", "find . -name '*$search*'") Try something like this, not tested: cmd, err := exec.Command("bash", "-c", fmt.Sprintf("find . -name %s", search)) -- You received this message

Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
On Fri, Sep 16, 2022 at 4:23 PM Robert Engels wrote: > Normally when people reply to the list it only comes from the list - and the > list is allow listed. All people in this thread sent their replies to both you and the list. > You are the first person in years to say anything about this.

Re: [go-nuts] Re: private go documentation server similar to https://pkg.go.dev

2022-09-12 Thread Jan Mercl
On Mon, Sep 12, 2022 at 10:01 AM brainman wrote: > I managed to run godoc. > > But godoc only displays standard library packages. > > Is it possible to configure godoc so it displays packages stored in private > github repos ? I use it with no configuration, '$ GO111MODULE=off godoc -http

Re: [go-nuts] Is this a possible bug with pipe

2022-09-12 Thread Jan Mercl
On Mon, Sep 12, 2022 at 11:16 PM ramki...@hotmail.com wrote: > > I created a TCP Proxy using io.copy (which creates a splice). Here is the > code. > > Proxy TCP Server - https://pastebin.com/iAcFjmV1 > Regular TCP Server - https://pastebin.com/V6AN7atV > > When using telent to port 8080, the

Re: [go-nuts] Re: private go documentation server similar to https://pkg.go.dev

2022-09-11 Thread Jan Mercl
On Sun, Sep 11, 2022 at 4:20 AM Rob Pike wrote: > It would be nice if gofmt still had its -http option. You could run an > old version. AFAICT, the option is still there. We're using it at work, installed on our gitlab server. me@3900x:~$ go install -v

Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
On Fri, Sep 16, 2022 at 4:42 PM Robert Engels wrote: > I don’t know what is happening. The message you just sent came from you not > the list. This is not how it is supposed to work. That is why there is a > problem. FYI, I'm posting to the list from the GMail web client. This time I have

Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
On Fri, Sep 16, 2022 at 7:43 AM robert engels wrote: > After some analysis and discussion, the sample I provided earlier has a data > race by definition - although in many cases these are benign and do no affect > the correctness of the program. There's no such thing [in Go and many other

Re: [go-nuts] Is this a possible bug with pipe

2022-09-14 Thread Jan Mercl
On Thu, Sep 15, 2022 at 1:53 AM ramki...@hotmail.com wrote: > When I submitted it as a bug, this is what I got. > https://github.com/golang/go/issues/55029 By chance, do you know what is a > buffering for io.Copy? https://cs.opensource.google/go/go/+/refs/tags/go1.19.1:src/io/io.go;l=385

Fwd: Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
a reply bot to spam my inbox, thank you. Otherwise I propose the admin of this list to ban your email. -- Forwarded message - From: Date: Fri, Sep 16, 2022 at 9:09 AM Subject: Re: Re: [go-nuts] Race detector question To: Jan Mercl <0xj...@gmail.com> I apo

Re: [go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread Jan Mercl
On Tue, Sep 20, 2022 at 6:02 PM peterGo wrote: > Yes, I read that too. A fundamental tenet of science is reproducibility. I > was able to reproduce the AMD64 results and documented it. A step forward. 5:24 PM (45 minutes ago) > I am unable to reproduce your results on AMD64. 6:02 PM (7 minutes

Re: [go-nuts] int64(math.Inf(+1)) != math.MaxInt64

2022-10-03 Thread Jan Mercl
On Tue, Oct 4, 2022 at 4:18 AM Jonathan Pearson wrote: > I expected int64(math.Inf(+1)) == math.MaxInt64, but it does not. Quoting from https://go.dev/ref/spec#Conversions, section "Conversions between numeric types" In all non-constant conversions involving floating-point or complex

Re: [go-nuts] Zero-sized data type

2022-10-12 Thread Jan Mercl
On Wed, Oct 12, 2022 at 6:01 PM Richiise Nugraha wrote: > Hi, I am looking for zero-sized data type, something like Flexible Array Member. > The size of `struct {}` is indeed zero, but for what reason when it's inside a struct with another member say (https://go.dev/play/p/DpydJIke7dS): > > type

Re: [go-nuts] How to add zero after a decimal point in float datatype

2022-10-12 Thread Jan Mercl
On Wed, Oct 12, 2022 at 9:31 PM pravin chaudhary wrote: > I need to add zero after a decimal point to a float datatype but not able to > do. > > Required float value = 5.00 but getting as 5 > > Datatype should be float only!! > > Any help will be much appreciated! Is this perhaps what you're

Re: [go-nuts] workspace question

2022-10-12 Thread Jan Mercl
On Wed, Oct 12, 2022 at 4:49 AM Steve Roth wrote: > > I'd appreciate help with setting up a workspace, involving two modules that exist only on my local disk and not in any SCM. I understand how to create the workspace and use both modules in it. What I can't figure out is how to add a

Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 1:37 AM Robert Engels wrote: > I don’t see any arguments refuting the claim? Can you include a link so the > analysis can be read in context? The word "coroutines" does not ring a bell? -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 7:36 PM Robert Solomon wrote: > https://go.dev/play/p/gIVVLsiTqod I believe wg.Add on line 125 is too late. I think it needs to be moved before the go statement on line 108. Not tested. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 1:16 PM Robert Engels wrote: > By many definitions Go routines and virtual threads are technically > coroutines - versus a platform/OS thread. Show one please. Coroutines are normally a subject of non-preemptive multitasking, threads are normally just the opposite. [0]

Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 2:47 PM Robert Engels wrote: > I already pointed that out.Go routines were non preemptive until recently. > They are also still non preemptive when calling a system call without direct > support, or CGo - it spins up another platform thread. I'm talking about a

Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 3:00 PM Robert Engels wrote: > They are still non-preemptive. Even the way preemption is implemented is > cooperative. Goroutines are preempted in a thread signal handler that invokes the Go runtime scheduler that in turn saves the required goroutine state and switches

Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 3:04 PM Robert Engels wrote: > One other thing, if you don’t think he knows exactly how Go routines are > implemented you are delusional. Maybe he should then fix the Wikipedia article I linked before. Good luck with that. PS: I assume you meant "goroutines" instead of

Re: [go-nuts] Re: gouse — toggle ‘declared but not used’ errors

2022-08-08 Thread Jan Mercl
Put `func use(...interface{}) {}` into any *_test.go file. Call it with any variable(s) that is/are temporarily unused during testing/debugging. It work also for unused imports by naming something from the package. The code does not compile outside of `$ go test`, it's not possible to forget and

Re: [go-nuts] Finding the go command from inside a test case

2022-08-11 Thread Jan Mercl
On Thu, Aug 11, 2022 at 9:59 AM Patrick Smith wrote: > To date, I've been using a recipe I found some time ago through an Internet > search (I've forgotten the source, so can't credit it): > > gocmd := runtime.GOROOT() + "/bin/go" > if runtime.GOOS == "windows" { >

Re: [go-nuts] Pipelining with Go and Generics

2022-08-11 Thread Jan Mercl
On Thu, Aug 11, 2022, 21:36 Robert Engels wrote: > I’d say it certainly highlights a problem with Go’s error model. > Exceptions would fit nicely here - instead it seems you needed to ignore > all error handling - because chaining is impossible with error returns. > It's okay if someone prefers

Re: [go-nuts] Pipelining with Go and Generics

2022-08-11 Thread Jan Mercl
ins. > > But like I said, I would use panic/recover in the framework to make it > easier. > > > > On Aug 11, 2022, at 3:27 PM, Jan Mercl <0xj...@gmail.com> wrote: > >  > > > On Thu, Aug 11, 2022, 21:36 Robert Engels wrote: > >> I’d say it certainly

Re: [go-nuts] Pipelining with Go and Generics

2022-08-12 Thread Jan Mercl
On Thu, Aug 11, 2022 at 11:18 PM Robert Engels wrote: > Every modern language with generics or similar has a streams package so > there’s no need to call out Java. For some reason unknown to me you seem to consider Go not being a modern language as it does not have a "streams" package. I don't

Re: [go-nuts] How to run a java file using go script.

2022-08-04 Thread Jan Mercl
On Thu, Aug 4, 2022 at 6:24 AM TECHAX wrote: > I tried the following one but still, it's not working. > > os.Setenv("PATH","/home/sdk/jdk-11.0.16/bin") > cmd,_:=exec.Command("java","-version").Output() > fmt.Println(string(cmd)) > > Since the path is set, so it should display the java version,

Re: [go-nuts] A pedantic question about updating a map during iteration

2022-08-03 Thread Jan Mercl
> For example, is this program guaranteed to print "1 1"? > https://go.dev/play/p/PeBEXKp1deH Yes, because the range iteration loop does not add/delete any items. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-01 Thread Jan Mercl
On Tue, Nov 1, 2022, 20:36 Frank Jüdes wrote: > I have to write a program that should verify the content of > configuration-servers. It will need a lot of pre-initialized data to verify > the actual content of a server, so it has to initialize many strings. What > i know from other C-style

Re: [go-nuts] Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-19 Thread Jan Mercl
On Mon, Dec 19, 2022 at 11:01 AM Torsten Bronger wrote: > The context documentation gives this example: > > // Stream generates values with DoSomething and sends them to out > // until DoSomething returns an error or ctx.Done is closed. > func Stream(ctx context.Context, out chan<-

Re: [go-nuts] Re: Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-20 Thread Jan Mercl
On Tue, Dec 20, 2022 at 9:21 AM Jason E. Aten wrote: > Shutting down goroutines quickly was needed so often that I wrote a package > to help me with it. it is called idem, short for idempotent. > > It uses the idea of an idempotent Close of a channel to signal that the > goroutine should stop.

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread Jan Mercl
On Tue, Nov 22, 2022 at 4:43 PM Robert Engels wrote: > Go is not listed as an OO language on Wikipedia. Check https://en.wikipedia.org/wiki/Go_(programming_language): "ParadigmMulti-paradigm: concurrent imperative, object-oriented[1][2]" > Personally I think it is OO-like. OO typically has

Re: [go-nuts] Module weirdness in playground

2022-11-18 Thread Jan Mercl
On Fri, Nov 18, 2022 at 7:15 PM Brian Candler wrote: > This used to work: > https://play.golang.org/p/YQoAu1Iwkor > > But now when I click on "Run", the import path of "example.com/myprog/foo" is > removed, and it fails to compile. > > Any clues as to what's going on? I think the playground

Re: [go-nuts] Int64 to []byte and vice-versa

2022-11-21 Thread Jan Mercl
On Mon, Nov 21, 2022 at 9:57 AM Nikhilesh Susarla wrote: > I have an int64 value say 12 > I want to convert that to []byte array. Such conversion is not supported. Also, []byte is a slice. However, the desired result can be computed in code. You can use the encoding/binary package for that.

Re: [go-nuts] Tool showing all assignemnts to the blank identifier

2022-11-28 Thread Jan Mercl
On Mon, Nov 28, 2022 at 1:44 PM Wojciech Muła wrote: > Is there any tool that would point out places with > an assignment to the blank identifier? > > I'd like to spot possible refactoring/debug leftovers, > like `_ := func() {}` or unused imports. > > I went through the staticcheck list of

Fwd: Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread Jan Mercl
language? To: Jan Mercl <0xj...@gmail.com> I apologize for this automatic reply to your email. To control spam, I now allow incoming messages only from senders I have approved beforehand. If you would like to be added to my list of approved senders, please fill out the short request for

Re: [go-nuts] Underscore symbol

2022-11-04 Thread Jan Mercl
On Fri, Nov 4, 2022 at 6:54 PM Canuto wrote: > I'm just starting out with go ... > I have searched for lights on this string but without success. > What does this sign mean " _, err " , what the underscore symbol means here ? > > func generateSalt() string { > randomBytes := make([]byte, 16) >

Re: [go-nuts] godoc and generic code

2022-11-03 Thread Jan Mercl
On Thu, Nov 3, 2022 at 12:49 PM Hotei wrote: > I added some generic code to a project and godoc doesn't seem to like that > and stops working when it sees the generics. It's a 4 year old version of > godoc so that's perhaps not a surprise. What is a surprise is that godoc > isn't shipped

Re: [go-nuts] Create a 1GB ballast but it takes up RSS and pages are Dirty?

2022-11-06 Thread Jan Mercl
On Sun, Nov 6, 2022 at 12:54 PM Kn (Kn) wrote: > Now the problem begins. I expect the ballast like `ballast := make([]byte, > 1<<30)` shouldn't take up any physical memory because there's no any writing > to it. The backing array is specified to be zeroed, so we cannot say there's no writing

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread Jan Mercl
On Tue, Nov 8, 2022 at 9:53 AM 'Mark' via golang-nuts wrote: > Given a function: > > func F[T comparable](a T) { > } > > is it possible to check T's type inside F? > > My use case is that I have a function with signature G[T comparable](x []T) > and inside G I want to sort the elements in slice

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread Jan Mercl
On Tue, Nov 8, 2022 at 10:56 AM 'Mark' via golang-nuts wrote: > // Want to sort by T < T // > elements := make([]string, 0, len(me)) > for element := range me { > elements = append(elements, fmt.Sprintf("%#v", element)) > } > sort.Strings(elements)

Re: [go-nuts] There is a passage in book that is difficult to understand, can anyone help explain it?

2022-11-02 Thread Jan Mercl
On Wed, Nov 2, 2022 at 5:35 PM Robert Engels wrote: > I think this can be disproven. > > Given a function A with a reentrant lock, it can be rewritten as A with > non-reentrant lock and A’ without a lock where A’ is the original A function > body. > > A’ would then be susceptible to the

Fwd: Re: [go-nuts] There is a passage in book that is difficult to understand, can anyone help explain it?

2022-11-02 Thread Jan Mercl
: Date: Wed, Nov 2, 2022 at 6:10 PM Subject: Re: Re: [go-nuts] There is a passage in book that is difficult to understand, can anyone help explain it? To: Jan Mercl <0xj...@gmail.com> I apologize for this automatic reply to your email. To control spam, I now allow incoming messages only from s

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

2023-03-26 Thread Jan Mercl
The only broken thing in the code below is the TestHello function. rsc.io/quote uses rsc.io/sampler where the Hello func (https://pkg.go.dev/rsc.io/sampler#Hello) is documented to return a localized string by default. Localized, in the sense of respecting the user's locale. That is not compatible

Re: [go-nuts] How to generalize parameters for a function

2023-03-15 Thread Jan Mercl
On Wed, Mar 15, 2023 at 11:03 AM Frank Jüdes wrote: > > Well, that didn't go very far: https://go.dev/play/p/UtsrRar9J0Q > Fails with the messages > ./prog.go:15:11: invalid operation: cannot index p_Map (variable of type MAP > constrained by DataMap) > ./prog.go:16:26: cannot range over p_Map

Re: [go-nuts] CGO Struct used as type parameter causes issue in Go 1.20

2023-02-16 Thread Jan Mercl
On Thu, Feb 16, 2023 at 8:22 AM Jan wrote: > Any thoughts ? A minimal, self-contained and runnable reproducer would be rather useful in this case. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Building Go 1.21 for openbsd/386

2023-02-22 Thread Jan Mercl
The subject target is not distributed by the Go team. Attempting to build if from sources in a qemu 4GB VM [OpenBSD 7.2 (GENERIC.MP) #404: Tue Sep 27 12:54:46 MDT 2022] via $ GOROOT_BOOTSTRAP=~/go1.19 nohup ./make.bash produces Building Go toolchain1 using /home/jnml/go1.19.

Re: [go-nuts] gofmt: expected declaration, found ')'

2023-04-16 Thread Jan Mercl
On Sun, Apr 16, 2023 at 12:51 PM Andreas Götz wrote: > Isn't gofmt ist part of the go command? Go ist the latest version: It is but it's a separate binary/executable file. Go version is one thing, the version of the binary file that is actually executed when '$ gofmt' is invoked is another

Re: [go-nuts] gofmt: expected declaration, found ')'

2023-04-16 Thread Jan Mercl
On Sun, Apr 16, 2023 at 12:17 PM Andreas Götz wrote: > > Good morning. Please excuse me for asking here- I'm stuck with something that > looks like a gofmt bug though that seems very unlikely. > > In CI > (https://github.com/evcc-io/evcc/actions/runs/4712710735/jobs/8357929411?pr=7485) > I'm

Re: [go-nuts] Re: Home directory?

2023-04-23 Thread Jan Mercl
On Sun, Apr 23, 2023 at 10:28 AM Amnon wrote: > Yes GOPATH and GOROOT have been deprecated. Both are alive and well. They are essential for the build system/go command to work as required. tl;dr: There's a default value of GOPATH so one does not have to set it. A much longer version can be

Fwd: [go-nuts] Redfining loop variable semantics - what's the plan?

2023-04-11 Thread Jan Mercl
Resending to the mailing list as that was my intention but I errored again. Did the gmail UI changed again? -- Forwarded message - From: Jan Mercl <0xj...@gmail.com> Date: Tue, Apr 11, 2023 at 9:11 AM Subject: Re: [go-nuts] Redfining loop variable semantics - what's th

Re: [go-nuts] Drain channel on demand without busy looping?

2023-02-05 Thread Jan Mercl
On Sun, Feb 5, 2023 at 5:12 PM cpu...@gmail.com wrote: > Would that still busy-loop? Are there better patterns? for range q.data {} iff the sending side properly closes the channel. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] SIGSEGV: segmentation violation on Linux/ARM with Microchip SAM9x60 (ARM926 core) processor

2023-02-09 Thread Jan Mercl
A user filled https://gitlab.com/cznic/sqlite/-/issues/132, but I'm not able to reproduce it on RPi 4 and I don't have access to the subj. chip/system. It might be possibly something HW related, IDK. Looking for expert advice for the linux/arm Go target. Anyone out there? Thanks in advance. -j

<    6   7   8   9   10   11   12   >