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] 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] 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] 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] 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] 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-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] 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] 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] 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 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] 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 <

[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] 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] 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] 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] 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-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-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] 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] 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] 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] 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-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] 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] 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] 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] 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] 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-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

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-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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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

[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] 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,

[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] 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() { >

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"

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] 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] 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-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] 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] 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] 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: 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: 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

[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: 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,

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] 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

[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] 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.

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] 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] 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] 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] 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] 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] Golang language specification Document: Composite Literals example is not understandable

2021-06-23 Thread Jan Mercl
On Wed, Jun 23, 2021 at 7:06 AM Vaibhav Maurya wrote: > I appreciate the whole discussion, it was really insightful. Since Golang is > not my first language, I had a preconceived notion about key-value pair > initialization. > Here I would like to disagree with the syntax, it would be good

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread Jan Mercl
On Tue, Jun 22, 2021 at 5:40 PM Vaibhav Maurya wrote: > https://golang.org/ref/spec#Composite_literals > > following is the search string for CTRL + F > // vowels[ch] is true if ch is a vowel \ > > Following declaration and initialization is confusing. > vowels := [128]bool{'a': true, 'e': true,

Re: [go-nuts] Representing Optional/Variant Types Idiomatically (or not)

2021-06-17 Thread Jan Mercl
On Thu, Jun 17, 2021 at 9:43 AM Joshua wrote: > 1) I'm modelling a data type which has a field which may or may not be >there, would most Gophers reach for a pointer here, and use `nil' to >represent a missing value? That's the usual approach seen in the wild and IMO often the wrong

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

2021-06-15 Thread Jan Mercl
On Mon, Jun 14, 2021 at 11:38 PM Ian Lance Taylor wrote: > Go 1.17 continues to support GOPATH mode if you explicitly set the > environment variable GO111MODULE=off. This is the same as Go 1.16. > See https://golang.org/ref/mod#mod-commands. Quoting from "New module changes in Go 1.16", 18

Re: [go-nuts] Are receiver copies atomic?

2021-06-08 Thread Jan Mercl
On Tue, Jun 8, 2021 at 12:08 PM Ian Davis wrote: > When a method with a non-pointer receiver is called, is the copy made > atomically? My intuition says it must be but perhaps someone else can confirm > it? I don't think the specs require that and I don't think well known implementations try

Re: [go-nuts] Does anyone konw which proposal changes the access for embeded field name of struct?

2021-06-07 Thread Jan Mercl
On Mon, Jun 7, 2021 at 11:20 AM Ally Dale wrote: > I want to know why golang change the access method. The name of the programming language is Go. > Anyone who knows the isssue link, please reply me. Thanks a lot. There's no proposal and there's no issue. It always worked like that. You

Re: [go-nuts] Query on using Closures

2021-06-06 Thread Jan Mercl
On Sun, Jun 6, 2021 at 8:44 PM 'Suveetha Kamatchi' via golang-nuts wrote: Please post code as plain text, no colors, no inverted schema in particular. Or share code via a link at play.golang.org, thank you. -- You received this message because you are subscribed to the Google Groups

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] Re: Is this a bug ?

2021-06-03 Thread Jan Mercl
On Thu, Jun 3, 2021 at 11:21 AM Brian Candler wrote: > > Weird. It simplifies to this: https://play.golang.org/p/OsOhRMC6kBu I think this case is WAI. >From https://golang.org/ref/spec#Operators " If the left operand of a non-constant shift expression is an untyped constant, it is first

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

2021-06-02 Thread Jan Mercl
On Wed, Jun 2, 2021 at 8:48 AM cheng dong wrote: > `y` escape because the println use interface{} as its parameter, println is a bootstrap function that the compiler knows about by itself. It's formal/pseudo signature does not use 'interface{}'. I haven't checked the actual implementation, but

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] Table-driven benchmarks defeat inlining

2021-06-01 Thread Jan Mercl
On Tue, Jun 1, 2021 at 12:29 AM Paul S. R. Chisholm wrote: > P.S.: Out of curiosity, how can I post a message with fancy code examples > like this one? > https://groups.google.com/g/golang-nuts/c/5DgtH2Alt_I/m/hlsqdRSGAgAJ FTR, that's not fancy in my books. Code is best posted to email

Re: [go-nuts] Value copy costs are not very predictable.

2021-05-30 Thread Jan Mercl
Within the benchmark loops of the linked code a sufficiently smart compiler can optimize the source values away completely and/or collapse all writes to the destination values to a single write. Have you looked at the actual code the CPU executes? > > -- You received this message because you

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] parameter name a of fmt package

2021-05-25 Thread Jan Mercl
On Tue, May 25, 2021 at 10:14 AM Delta Echo wrote: > What does the parameter name `a` stands for in fmt package's functions? > func Printf(format string, a ...interface{}) (n int, err error) > > Is it argument? It's a parameter name. ...interface{} is the type of that argument, variadic in

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

2021-05-23 Thread Jan Mercl
On Sun, May 23, 2021 at 11:11 AM tapi...@gmail.com wrote: > > It says both "make([]T, N) does not escape" and "make([]T, N) escapes to > heap" for the slice allocated by g. What's conflicting about? You still did not explain that. I noted before that the code is different. Yes, the different

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

2021-05-23 Thread Jan Mercl
On Sun, May 23, 2021 at 11:01 AM tapi...@gmail.com wrote: > And how to interpret the conflicting messages for the following program? Please share what conflict and where do you see it. I see only different escape/does not escape status for different code but nothing conflicting. -- You

Re: [go-nuts] Syscalls that take structs with embedded pointers

2021-05-14 Thread Jan Mercl
On Fri, May 14, 2021 at 12:36 PM sh...@tigera.io wrote: > One way I could see to solve this would be to do some manual memory > management with MMap or BRK to allocate the buffer but I wondered if there > was an easier way? IMO using manual memory management _is_ the easy way in this case.

<    1   2   3   4   5   6   7   8   9   10   >