[go-nuts] Re: clean unused packages in $GOPATH/pkg/mod

2020-07-06 Thread Amnon
Just delete them all. Your next build will repopulate the ones that are needed. -- 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] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread Steven Blenkinsop
On Mon, Jul 6, 2020 at 6:29 PM, roger peppe wrote: > > I've also been playing around in this area. I've been trying something > similar to this approach: https://go2goplay.golang.org/p/sHko_EMhJjA > But this isn't ideal - note that we lose type safety when assigning back > to the generic hash

Re: [go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-06 Thread Marcin Romaszewicz
Thanks for the tip, I wasn't aware that happened! I'll use os.Pipe. -- Marcin On Mon, Jul 6, 2020 at 4:45 PM Ian Lance Taylor wrote: > On Mon, Jul 6, 2020 at 4:42 PM Marcin Romaszewicz > wrote: > > > > Yes, I am using io.Pipe, and passing in the PipeWriter side of it as > Stdout and Stderr

Re: [go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread Robert Engels
I only meant that the “socket closed” error is a good (perfect?) signal that the Go routine should exit rather than using an additional state var. > On Jul 6, 2020, at 6:43 PM, Ian Lance Taylor wrote: > > On Mon, Jul 6, 2020 at 4:23 PM robert engels wrote: >> >> If you set the deadline to

Re: [go-nuts] pure function on golang

2020-07-06 Thread Kurniagusta Dwinto
> i would value "pure" if it were a contract for early evaluation does this "early evaluation" concern about IO? like loading blob data with ioutil.ReadFile into global variable at compile time? > Well, C++ is a very different language with very different goals. I > think history shows that C++

Re: [go-nuts] pure function on golang

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 5:11 PM Kurniagusta Dwinto wrote: > > > It's not obvious to me that "pure" is a characteristic that is important > > enough > > to be singled out and added to the language > > the name "pure" may be debatable, but the characteristic is the same with > "constexpr" in C++,

Re: [go-nuts] pure function on golang

2020-07-06 Thread Michael Jones
i would value "pure" if it were a contract for early evaluation. in my post on this from 2018 (linked above), the reasoning was so that "x := math.Sin(0.23)" would be a compile-time event. On Mon, Jul 6, 2020 at 5:11 PM Kurniagusta Dwinto wrote: > > It's not obvious to me that "pure" is a

Re: [go-nuts] pure function on golang

2020-07-06 Thread Kurniagusta Dwinto
> It's not obvious to me that "pure" is a characteristic that is important enough > to be singled out and added to the language the name "pure" may be debatable, but the characteristic is the same with "constexpr" in C++, although I also don't have a strong reason why this is important beside

Re: [go-nuts] pure function on golang

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 4:52 PM Kurniagusta Dwinto wrote: > > Adding pure marker will give information to the programmer that the function > will not do any side effect, the compiler just gives compile error when the > programmer disagrees about the contract, like doing IO operation on pure >

Re: [go-nuts] pure function on golang

2020-07-06 Thread Kurniagusta Dwinto
Additionally, this feature complement new generic feature, this feature will help anyone that trying to use functional programming pattern (like monad pattern) in their code On Tuesday, July 7, 2020 at 6:52:31 AM UTC+7 Kurniagusta Dwinto wrote: > Adding pure marker will give information to the

Re: [go-nuts] pure function on golang

2020-07-06 Thread Kurniagusta Dwinto
Adding pure marker will give information to the programmer that the function will not do any side effect, the compiler just gives compile error when the programmer disagrees about the contract, like doing IO operation on pure function. So in the end, this feature focuses on helping the

Re: [go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 4:42 PM Marcin Romaszewicz wrote: > > Yes, I am using io.Pipe, and passing in the PipeWriter side of it as Stdout > and Stderr on Cmd. I'm glad you figured out the problem, but I want to note that you almost certainly want to be using os.PIpe rather than io.Pipe. io.Pipe

Re: [go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 4:23 PM robert engels wrote: > > If you set the deadline to zero, don’t you need to use another flag to know > that it “should be terminated”, otherwise you can’t know if the deadline > exceeded was regular - I guess, unless you do a “get deadline” on the error > and

Re: [go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-06 Thread Marcin Romaszewicz
Yes, I am using io.Pipe, and passing in the PipeWriter side of it as Stdout and Stderr on Cmd. I figured out the problem, though. The executable which I am launching is doing a write on a non-existent file descriptor upon shutdown, which generates a SIGPIPE, per strace: write(75,

Re: [go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread robert engels
If you set the deadline to zero, don’t you need to use another flag to know that it “should be terminated”, otherwise you can’t know if the deadline exceeded was regular - I guess, unless you do a “get deadline” on the error and check for 0, but that seems racy ? > On Jul 6, 2020, at 1:36 PM,

Re: [go-nuts] pure function on golang

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 3:11 PM bugpowder wrote: > > I'd guess the compiler could then enforce it (see if any non-pure marked > function is called from a pure one), it could exploit it (e.g. play with > evaluation order, cache, etc), and other such things? The compiler can already tell whether

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread roger peppe
On Mon, 6 Jul 2020 at 17:46, wrote: > Hi! > > I've spent some time lately to try out the go2go tool and the new generics > proposal by converting a small hack I did some years ago for immutable data > structures (https://github.com/tobgu/peds) which, in it's current shape, > depends on code

Re: [go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-06 Thread Ian Lance Taylor
On Sun, Jul 5, 2020 at 4:14 PM Marcin Romaszewicz wrote: > > On Sun, Jul 5, 2020 at 1:05 PM Ian Lance Taylor wrote: >> >> On Sun, Jul 5, 2020 at 10:54 AM Marcin Romaszewicz wrote: >> > >> > I'm hitting a problem using os.exec Cmd.Start to run a process. >> > >> > I'm setting Cmd.Stdio and

Re: [go-nuts] pure function on golang

2020-07-06 Thread Michael Jones
prior discussion: https://groups.google.com/forum/#!searchin/Golang-Nuts/pure$20functions/golang-nuts/ZVeMxBBVpa4/slidZL9KBAAJ On Mon, Jul 6, 2020 at 3:11 PM bugpowder wrote: > I'd guess the compiler could then enforce it (see if any non-pure marked > function is called from a pure one), it

Re: [go-nuts] pure function on golang

2020-07-06 Thread bugpowder
I'd guess the compiler could then enforce it (see if any non-pure marked function is called from a pure one), it could exploit it (e.g. play with evaluation order, cache, etc), and other such things? On Tue, Jul 7, 2020 at 1:00 AM Ian Lance Taylor wrote: > On Mon, Jul 6, 2020 at 9:47 AM wrote:

Re: [go-nuts] pure function on golang

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 9:47 AM wrote: > > Hi, I don't know if this kind of idea is already discussed before. > > I have an idea of adding pure function marker/type on golang, it is just like > "constexpr" on C++ or "const fn" on Rust, whether this function is evaluated > at compile time if the

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 9:46 AM wrote: > > I've spent some time lately to try out the go2go tool and the new generics > proposal by converting a small hack I did some years ago for immutable data > structures (https://github.com/tobgu/peds) which, in it's current shape, > depends on code

[go-nuts] SFTPGo 1.0.0 Released

2020-07-06 Thread Nicola Murino
Hi all, I'm pleased to finally announce SFTPGo 1.0.0! SFTPGo is a free and open source fully featured and highly configurable SFTP server. It works on Linux, macOS and Windows. Here are the main new features compared to 0.9.6 version: - Support for SSH Multi-Step authentication. - Support for

Re: [go-nuts] godoc.org pkg.go.dev banner feedback

2020-07-06 Thread Jan Mercl
On Mon, Jul 6, 2020 at 9:03 PM 'Jonathan Amsterdam' via golang-nuts wrote: > Fixed in production. The links work now. Happy to confirm. Many thanks to everyone involved in making it happen. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] godoc.org pkg.go.dev banner feedback

2020-07-06 Thread 'Jonathan Amsterdam' via golang-nuts
Fixed in production. The links work now. On Monday, July 6, 2020 at 12:47:34 PM UTC-4 Julie Qiu wrote: > Thanks for letting us know! This looks like a bug - we'll look into it. I > filed an issue here: https://github.com/golang/go/issues/40071 > > > On Thursday, July 2, 2020 at 12:00:57 PM

Re: [go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 10:57 AM Robert Engels wrote: > > You need to close the socket from another Go routine. Otherwise the Reader > api would need to be changed to always take a Context. Either close the socket or set the deadline to zero. Ian > On Jul 6, 2020, at 12:36 PM, Brian Candler

Re: [go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread Robert Engels
You need to close the socket from another Go routine. Otherwise the Reader api would need to be changed to always take a Context. > On Jul 6, 2020, at 12:36 PM, Brian Candler wrote: > >  >> On Monday, 6 July 2020 14:53:55 UTC+1, Ian Davis wrote: >> Can you write your own ContextReader that

Re: [go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread Brian Candler
On Monday, 6 July 2020 14:53:55 UTC+1, Ian Davis wrote: > > Can you write your own ContextReader that checks ctx.Done in its Read > method? > > Inside a ContextReader I can check ctx.Done *before* calling the wrapped Read method - but if the context isn't done at that point and I called the

[go-nuts] I need help with a timer.

2020-07-06 Thread Khan
Hey! I'm pretty new to prgramming in general and i've been trying to figure out something for a little while now and just couldn't get it done. So i decided to ask for help here! I just wanted to programm a simple timer that will print a certain text after a certain amount of time (900

Re: [go-nuts] godoc.org pkg.go.dev banner feedback

2020-07-06 Thread julieqiu via golang-nuts
Thanks for letting us know! This looks like a bug - we'll look into it. I filed an issue here: https://github.com/golang/go/issues/40071 On Thursday, July 2, 2020 at 12:00:57 PM UTC-4, Russ Cox wrote: > > Thanks for the feedback Jan. Google is on an extended holiday weekend for > the US holiday

[go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread tobias . l . gustafsson
Hi! I've spent some time lately to try out the go2go tool and the new generics proposal by converting a small hack I did some years ago for immutable data structures (https://github.com/tobgu/peds) which, in it's current shape, depends on code generation. There is nothing really mind bending

[go-nuts] pure function on golang

2020-07-06 Thread kurnia . d . win
Hi, I don't know if this kind of idea is already discussed before. I have an idea of adding pure function marker/type on golang, it is just like "constexpr" on C++ or "const fn" on Rust, whether this function is evaluated at compile time if the input is known at compile time is another

Re: [go-nuts] Go program getting SIGSEGV as it panics and runs down after a SIGTERM or a SIGINT signal

2020-07-06 Thread estess
Ian, Thankyou VERY much for your reply. Your analysis was spot-on. There is a 3rd way that a goroutine could have the stack ripped out from under it - if it is running a signal handler. Go uses the SA_ONSTACK (alternate signal stack) facility which we had adopted for YottaDB as well. Back when

[go-nuts] Re: Go program getting SIGSEGV as it panics and runs down after a SIGTERM or a SIGINT signal

2020-07-06 Thread estess
Thanks for the reply Charles. I did look into this but did not find anything further along these lines. -- 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] Clean shutdown when blocked on I/O

2020-07-06 Thread Ross Light
See https://golang.org/issue/20280 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web

Re: [go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread Ian Davis
Can you write your own ContextReader that checks ctx.Done in its Read method? On Mon, 6 Jul 2020, at 2:40 PM, Brian Candler wrote: > I am looking for the safe way to do a clean shutdown when blocked on I/O. > Here is a basic example: > > package main > > import ( > "encoding/json" > "fmt" >

[go-nuts] Clean shutdown when blocked on I/O

2020-07-06 Thread Brian Candler
I am looking for the safe way to do a clean shutdown when blocked on I/O. Here is a basic example: package main import ( "encoding/json" "fmt" "io" "os" "os/signal" "syscall" ) func main() { rx := json.NewDecoder(os.Stdin) chanTERM := make(chan os.Signal, 1) signal.Notify(chanTERM,

[go-nuts] Re: What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-06 Thread Brian Candler
This sounds to me like a sequencing issue, but the way you've describe it sounds correct. Can you share a trimmed-down bit of code? The key point is, in the goroutine that reads from the pipe, keep reading until eof and *then* close the pipe. If you close the pipe outside this goroutine,