Re: [go-nuts] Re: Reading os.Stdin, Unbuffered
Hi, Looking at the repository I see there are termios_darwin_amd64, termios_freebsd_amd64, and termios_linux_amd64 files. That package has code for these three operating systems, but no windows support. A terminal on a different OS isn't as standardized as you seem to assume. Robert Solomonschrieb am Mi., 29. Nov. 2017, 02:03: > I trying to learn how to use pseudo-terminal-go. It works fine under > Ubuntu 16.04 amd64. But not fine on win10 64 bit. > > go get github.com/carmark/pseudo-terminal-go/terminal > > #github.com/carmark/pseudo-terminal-go/terminal > github.com\carmark\pseudo-terminal-go\terminal\terminal.go:715:15: > Undefined State > github.com\carmark\pseudo-terminal-go\terminal\terminal.go:719:2:: > Undefined Restore > github.com\carmark\pseudo-terminal-go\terminal\terminal.go:724:18: > Undefined MakeRaw > > I tried it with the -u flag also and got the same result. And it doesn't > matter if I use \ or / on that command line. > > I also use github's termbox-go on this win10 box, and that works fine. > > What's up? > > --rob solomon > > > On Monday, November 27, 2017 at 9:59:52 AM UTC-5, dc0d wrote: >> >> Is there a way to read from `os.Stdin` in an unbuffered way? (Not waiting >> for a `\n` or anything). >> > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: ssh access
Hi, When you get the password dialog, your connection was made without the ssh key. You will need both versions of your private key. The putty ppk file for putty and the openssh one for your program. Btw, you could install something like the git bash shell on your windows system, this contains a ssh client that works with the openssh version of your key. tacticianschrieb am Di., 28. Nov. 2017, 20:48: > Alexei, converted key to openssh, but when I tried to access my ubuntu > server I was asked for a password, wg=hich I do not have - just passphrase. > So not sure openssh key will do it for me. > > > On Tuesday, 28 November 2017 15:19:44 UTC, tactician wrote: > >> Hi, am trying to access a ubuntu server running Go from a windows >> machine. My ubuntu access is via a PuTTy ssh-rsa private/public key. I am >> now seeking to access my server from a Go program on windows. All attempts >> to cobble together something using ssh that compiles have failed. Any >> suggestions. I cannot change my server or client. >> > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] net/http Server Shutdown does not free up the port upon return
net/http's Shutdown() does not free up the port upon return, or rather it seems a bit undefined how long it takes for the port to be reusable again. server := { Addr: fmt.Sprintf(":9000"), } go func() { fmt.Println("hosting...") err := server.ListenAndServe() }() time.Sleep(1 * time.Second) fmt.Println("closing") err := server.Shutdown(nil) fmt.Println("shutdown error", err) fmt.Println("hosting again...") err = server.ListenAndServe() fmt.Println("host again err", err) The code above, for example, sometimes successfully hosting the http server twice, but sometimes, the second one fails with "address already in use" error $ go run main.go hosting... closing shutdown error hosting again... // This is okay $ go run main.go hosting... closing shutdown error hosting again... host again err listen tcp :9000: bind: address already in use My question is, is this a bug, or an expected undetermined behavior? If it's the latter, how can I safely make sure that Shutdown() completely frees up the port used? -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Reading os.Stdin, Unbuffered
I trying to learn how to use pseudo-terminal-go. It works fine under Ubuntu 16.04 amd64. But not fine on win10 64 bit. go get github.com/carmark/pseudo-terminal-go/terminal #github.com/carmark/pseudo-terminal-go/terminal github.com\carmark\pseudo-terminal-go\terminal\terminal.go:715:15: Undefined State github.com\carmark\pseudo-terminal-go\terminal\terminal.go:719:2:: Undefined Restore github.com\carmark\pseudo-terminal-go\terminal\terminal.go:724:18: Undefined MakeRaw I tried it with the -u flag also and got the same result. And it doesn't matter if I use \ or / on that command line. I also use github's termbox-go on this win10 box, and that works fine. What's up? --rob solomon On Monday, November 27, 2017 at 9:59:52 AM UTC-5, dc0d wrote: > > Is there a way to read from `os.Stdin` in an unbuffered way? (Not waiting > for a `\n` or anything). > -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: ssh access
Do you use something like: func privateKey(file string, passphrase []byte) ssh.AuthMethod { buffer, err := ioutil.ReadFile(file) if err != nil { return nil } key, err := ssh.ParsePrivateKeyWithPassphrase(buffer, passphrase) if err != nil { return nil } return ssh.PublicKeys(key) } to read private key? Alexei On Tuesday, November 28, 2017 at 1:48:06 PM UTC-6, tactician wrote: > > Alexei, converted key to openssh, but when I tried to access my ubuntu > server I was asked for a password, wg=hich I do not have - just passphrase. > So not sure openssh key will do it for me. > > On Tuesday, 28 November 2017 15:19:44 UTC, tactician wrote: >> >> Hi, am trying to access a ubuntu server running Go from a windows >> machine. My ubuntu access is via a PuTTy ssh-rsa private/public key. I am >> now seeking to access my server from a Go program on windows. All attempts >> to cobble together something using ssh that compiles have failed. Any >> suggestions. I cannot change my server or client. >> > -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: ssh access
Alexei, converted key to openssh, but when I tried to access my ubuntu server I was asked for a password, wg=hich I do not have - just passphrase. So not sure openssh key will do it for me. On Tuesday, 28 November 2017 15:19:44 UTC, tactician wrote: > > Hi, am trying to access a ubuntu server running Go from a windows machine. > My ubuntu access is via a PuTTy ssh-rsa private/public key. I am now > seeking to access my server from a Go program on windows. All attempts to > cobble together something using ssh that compiles have failed. Any > suggestions. I cannot change my server or client. > -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: ssh access
The slex reference looks to decrypt an openssh file with a DEK-Info of DES-EDE3-CBC. However, I am coming from a PuTTy formatted key, which is different - hence my opening statement. So my question becomes a simple one - Do the Go (de-)crypt libraries handle PuTTy private keys with passphrase or just openssh? Otherwise my project seems to have hit a stonewall. On Tuesday, 28 November 2017 15:19:44 UTC, tactician wrote: > > Hi, am trying to access a ubuntu server running Go from a windows machine. > My ubuntu access is via a PuTTy ssh-rsa private/public key. I am now > seeking to access my server from a Go program on windows. All attempts to > cobble together something using ssh that compiles have failed. Any > suggestions. I cannot change my server or client. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] chan chan Job per worker vs. single chan Job
Why have long-lived worker goroutines at all? If you're just trying to limit the number of jobs in flight, a semaphore is usually simpler. (A `chan struct{}` or `chan bool` works fine as a simple semaphore; for more complex use-cases, there are several semaphore packages on godoc.org. Personally, I'm partial to https://godoc.org/golang.org/x/sync/semaphore.) If the workers need some resource that is only available in fixed quantities, it's still usually simpler to store and distribute the resources (e.g. in a buffered channel) rather than the jobs. As rog notes, a more complete example might be helpful. On Friday, November 24, 2017 at 12:57:04 PM UTC-5, Michael Jones wrote: > > having workers pull from a single queue is an excellent approach. (unless > you pull more than 3 million items per second from that queue :-) > > On Fri, Nov 24, 2017 at 2:11 AM, roger peppe> wrote: > >> On 24 November 2017 at 05:46, >> wrote: >> > Hi! >> > >> > This should be covered somewhere already but I can't find it. So here's >> my >> > question: >> > >> > Assume N workers running in a goroutine each and a number of Job tasks >> > coming in. >> > >> > The consensus appears to be to have one dispatcher goroutine collecting >> all >> > jobs, then pulling a ready worker from a single queue of worker >> channels. >> >> What do you base that consensus on? Having all workers pull from >> a single shared channel seems like a fine way to do things. >> >> It would help if you could provide some more complete code - the >> snippets you provided don't really make sense on their own to me. >> >> -- >> 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...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Michael T. Jones > michae...@gmail.com > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Reading os.Stdin, Unbuffered
Use https://godoc.org/golang.org/x/crypto/ssh/terminal#MakeRaw to set raw mode on the stdin terminal. Then you can just read from os.Stdin into a single byte buffer. If the read completes, then a key was pressed. On Tuesday, November 28, 2017 at 12:12:44 AM UTC-5, dc0d wrote: > > For example I want the program to exit, if any key has been pressed on > keyboard. I can not find any way to skip the wait for a necessary split > character (like '\n'). > > On Monday, November 27, 2017 at 6:36:35 PM UTC+3:30, Jan Mercl wrote: >> >> On Mon, Nov 27, 2017 at 4:00 PM dc0dwrote: >> >> > Is there a way to read from `os.Stdin` in an unbuffered way? (Not >> waiting for a `\n` or anything). >> >> n, err := os.Stdin.Read(buf) >> >> does not wait for `\n`. Or do you actually mean setting a terminal in raw >> mode? Because os.Stdin does not have to be a terminal. >> >> >> >> -- >> >> -j >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: ssh access
Go cannot parse keys generated by PuTTy. To output key parseable by Go you need to select Conversions -> Export OpenSSH key from menu in PUTTYGEN. Alexei On Tuesday, November 28, 2017 at 9:19:44 AM UTC-6, tactician wrote: > > Hi, am trying to access a ubuntu server running Go from a windows machine. > My ubuntu access is via a PuTTy ssh-rsa private/public key. I am now > seeking to access my server from a Go program on windows. All attempts to > cobble together something using ssh that compiles have failed. Any > suggestions. I cannot change my server or client. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps
Huh... I could have sworn that I tried it. Thx! On Tue, Nov 28, 2017, 5:59 PM roger peppewrote: > On 28 November 2017 at 16:30, Henrik Johansson > wrote: > > Ok, thanks for the clarification. > > > > Is there some way to reliably handle these situations? > > I really like the idea of custom value types as keys. > > As I did in my play.golang.org link, and others have pointed out too, > you can do it by implementing UnmarshalText on the pointer type, not > the value type. > https://play.golang.org/p/VQPBwnh4Jn > > cheers, > rog. > > > > > > On Tue, Nov 28, 2017, 5:22 PM roger peppe wrote: > >> > >> > What tripped me up aside from reusing the map in the example was that > in > >> > case of errors a value type will still be put in the with it's > default value > >> > which my or may not for me. > >> > >> The reason for that is that your UnmarshalText method was being called > >> on a pointer to the zero value, > >> but was a value method, so the value was copied (all value methods are > >> implemented by pointer > >> values too), then your method couldn't change the original value, so > >> the JSON unmarshaler > >> just saw the zero value unchanged. > >> > >> On 28 November 2017 at 16:10, Henrik Johansson > >> wrote: > >> > The time example I have was just an example. > >> > I have a trivial struct as key. > >> > > >> > What tripped me up aside from reusing the map in the example was that > in > >> > case of errors a value type will still be put in the with it's default > >> > value > >> > which my or may not for me. I avoided the whole thing by just using > >> > strings > >> > as the key. A bit less typed but not unmanageable. > >> > > >> > Thanks for clarifying everyone! > >> > > >> > > >> > On Tue, Nov 28, 2017, 3:34 PM Marvin Renich wrote: > >> >> > >> >> * Henrik Johansson [171128 07:43]: > >> >> > But wouldn't unmarshal just overwrite in case of more trivial keys? > >> >> > > >> >> > So pointer receivers on the marshaling methods is better. > >> >> > I think I tried it but something else blew up. > >> >> > >> >> While MarshalText can use a value or pointer receiver, it makes no > >> >> sense > >> >> to use a value receiver with UnmarshalText. The UnmarshalText method > >> >> must be able to change the caller's copy of the variable that is to > >> >> hold > >> >> the unmarshalled data. > >> >> > >> >> As for time.Time, if you read its documentation, it says that it > holds > >> >> both a wall clock time and a monotonic time. time.Now() returns a > >> >> structure that has both values, but some operations (e.g. time.Parse > >> >> and > >> >> time.Time.UnmarshalJSON) return a time.Time that only has a wall > clock > >> >> time. t.Round(0) is the canonical way to strip the monotonic time > from > >> >> a time.Time value t. > >> >> > >> >> So after t := time.Now(); t2 := t.Round(0), t and t2 represent the > same > >> >> wall clock time, but compare as different, because the t has both > wall > >> >> clock and monotonic times, whereas t2 only has wall clock time. > >> >> > >> >> So your map with key time.Now() has a key with both times. When you > >> >> marshal it, the marshalled value only has wall clock time. When you > >> >> unmarshal it back to the same map, the unmarshalled time is different > >> >> (but represents the same wall clock time) from the existing map key, > so > >> >> it creates an additional map element with the new key. > >> >> > >> >> If you create your map with keys that only have wall clock times with > >> >> UTC location, as in https://play.golang.org/p/BCB3TAZADB, the > >> >> unmarshalled key will match the existing key and overwrite it. If > you > >> >> remove either .UTC() or .Round(0) or both from that code, you will > >> >> notice that the map keys are different, and you end up with two > values > >> >> in the map after unmarshalling. > >> >> > >> >> ...Marvin > >> >> > >> >> -- > >> >> 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. > >> >> For more options, visit https://groups.google.com/d/optout. > >> > > >> > -- > >> > 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. > >> > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps
On 28 November 2017 at 16:30, Henrik Johanssonwrote: > Ok, thanks for the clarification. > > Is there some way to reliably handle these situations? > I really like the idea of custom value types as keys. As I did in my play.golang.org link, and others have pointed out too, you can do it by implementing UnmarshalText on the pointer type, not the value type. https://play.golang.org/p/VQPBwnh4Jn cheers, rog. > > > On Tue, Nov 28, 2017, 5:22 PM roger peppe wrote: >> >> > What tripped me up aside from reusing the map in the example was that in >> > case of errors a value type will still be put in the with it's default >> > value >> > which my or may not for me. >> >> The reason for that is that your UnmarshalText method was being called >> on a pointer to the zero value, >> but was a value method, so the value was copied (all value methods are >> implemented by pointer >> values too), then your method couldn't change the original value, so >> the JSON unmarshaler >> just saw the zero value unchanged. >> >> On 28 November 2017 at 16:10, Henrik Johansson >> wrote: >> > The time example I have was just an example. >> > I have a trivial struct as key. >> > >> > What tripped me up aside from reusing the map in the example was that in >> > case of errors a value type will still be put in the with it's default >> > value >> > which my or may not for me. I avoided the whole thing by just using >> > strings >> > as the key. A bit less typed but not unmanageable. >> > >> > Thanks for clarifying everyone! >> > >> > >> > On Tue, Nov 28, 2017, 3:34 PM Marvin Renich wrote: >> >> >> >> * Henrik Johansson [171128 07:43]: >> >> > But wouldn't unmarshal just overwrite in case of more trivial keys? >> >> > >> >> > So pointer receivers on the marshaling methods is better. >> >> > I think I tried it but something else blew up. >> >> >> >> While MarshalText can use a value or pointer receiver, it makes no >> >> sense >> >> to use a value receiver with UnmarshalText. The UnmarshalText method >> >> must be able to change the caller's copy of the variable that is to >> >> hold >> >> the unmarshalled data. >> >> >> >> As for time.Time, if you read its documentation, it says that it holds >> >> both a wall clock time and a monotonic time. time.Now() returns a >> >> structure that has both values, but some operations (e.g. time.Parse >> >> and >> >> time.Time.UnmarshalJSON) return a time.Time that only has a wall clock >> >> time. t.Round(0) is the canonical way to strip the monotonic time from >> >> a time.Time value t. >> >> >> >> So after t := time.Now(); t2 := t.Round(0), t and t2 represent the same >> >> wall clock time, but compare as different, because the t has both wall >> >> clock and monotonic times, whereas t2 only has wall clock time. >> >> >> >> So your map with key time.Now() has a key with both times. When you >> >> marshal it, the marshalled value only has wall clock time. When you >> >> unmarshal it back to the same map, the unmarshalled time is different >> >> (but represents the same wall clock time) from the existing map key, so >> >> it creates an additional map element with the new key. >> >> >> >> If you create your map with keys that only have wall clock times with >> >> UTC location, as in https://play.golang.org/p/BCB3TAZADB, the >> >> unmarshalled key will match the existing key and overwrite it. If you >> >> remove either .UTC() or .Round(0) or both from that code, you will >> >> notice that the map keys are different, and you end up with two values >> >> in the map after unmarshalling. >> >> >> >> ...Marvin >> >> >> >> -- >> >> 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. >> >> For more options, visit https://groups.google.com/d/optout. >> > >> > -- >> > 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. >> > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: ssh access
This may help, also: https://github.com/crosbymichael/slex/blob/master/ssh.go#L200 -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps
Ok, thanks for the clarification. Is there some way to reliably handle these situations? I really like the idea of custom value types as keys. On Tue, Nov 28, 2017, 5:22 PM roger peppewrote: > > What tripped me up aside from reusing the map in the example was that in > case of errors a value type will still be put in the with it's default > value which my or may not for me. > > The reason for that is that your UnmarshalText method was being called > on a pointer to the zero value, > but was a value method, so the value was copied (all value methods are > implemented by pointer > values too), then your method couldn't change the original value, so > the JSON unmarshaler > just saw the zero value unchanged. > > On 28 November 2017 at 16:10, Henrik Johansson > wrote: > > The time example I have was just an example. > > I have a trivial struct as key. > > > > What tripped me up aside from reusing the map in the example was that in > > case of errors a value type will still be put in the with it's default > value > > which my or may not for me. I avoided the whole thing by just using > strings > > as the key. A bit less typed but not unmanageable. > > > > Thanks for clarifying everyone! > > > > > > On Tue, Nov 28, 2017, 3:34 PM Marvin Renich wrote: > >> > >> * Henrik Johansson [171128 07:43]: > >> > But wouldn't unmarshal just overwrite in case of more trivial keys? > >> > > >> > So pointer receivers on the marshaling methods is better. > >> > I think I tried it but something else blew up. > >> > >> While MarshalText can use a value or pointer receiver, it makes no sense > >> to use a value receiver with UnmarshalText. The UnmarshalText method > >> must be able to change the caller's copy of the variable that is to hold > >> the unmarshalled data. > >> > >> As for time.Time, if you read its documentation, it says that it holds > >> both a wall clock time and a monotonic time. time.Now() returns a > >> structure that has both values, but some operations (e.g. time.Parse and > >> time.Time.UnmarshalJSON) return a time.Time that only has a wall clock > >> time. t.Round(0) is the canonical way to strip the monotonic time from > >> a time.Time value t. > >> > >> So after t := time.Now(); t2 := t.Round(0), t and t2 represent the same > >> wall clock time, but compare as different, because the t has both wall > >> clock and monotonic times, whereas t2 only has wall clock time. > >> > >> So your map with key time.Now() has a key with both times. When you > >> marshal it, the marshalled value only has wall clock time. When you > >> unmarshal it back to the same map, the unmarshalled time is different > >> (but represents the same wall clock time) from the existing map key, so > >> it creates an additional map element with the new key. > >> > >> If you create your map with keys that only have wall clock times with > >> UTC location, as in https://play.golang.org/p/BCB3TAZADB, the > >> unmarshalled key will match the existing key and overwrite it. If you > >> remove either .UTC() or .Round(0) or both from that code, you will > >> notice that the map keys are different, and you end up with two values > >> in the map after unmarshalling. > >> > >> ...Marvin > >> > >> -- > >> 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. > >> For more options, visit https://groups.google.com/d/optout. > > > > -- > > 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. > > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: ssh access
Okay. I haven't done that specifically -- just with password and RSA key *without* passphrase. But a Google search turned this up with an accepted answer, so maybe this will help, or hopefully someone else will chime in. https://stackoverflow.com/questions/42105432/how-to-use-an-encrypted-private-key-with-golang-ssh -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: ssh access
yes On Tuesday, 28 November 2017 15:19:44 UTC, tactician wrote: > > Hi, am trying to access a ubuntu server running Go from a windows machine. > My ubuntu access is via a PuTTy ssh-rsa private/public key. I am now > seeking to access my server from a Go program on windows. All attempts to > cobble together something using ssh that compiles have failed. Any > suggestions. I cannot change my server or client. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps
The time example I have was just an example. I have a trivial struct as key. What tripped me up aside from reusing the map in the example was that in case of errors a value type will still be put in the with it's default value which my or may not for me. I avoided the whole thing by just using strings as the key. A bit less typed but not unmanageable. Thanks for clarifying everyone! On Tue, Nov 28, 2017, 3:34 PM Marvin Renichwrote: > * Henrik Johansson [171128 07:43]: > > But wouldn't unmarshal just overwrite in case of more trivial keys? > > > > So pointer receivers on the marshaling methods is better. > > I think I tried it but something else blew up. > > While MarshalText can use a value or pointer receiver, it makes no sense > to use a value receiver with UnmarshalText. The UnmarshalText method > must be able to change the caller's copy of the variable that is to hold > the unmarshalled data. > > As for time.Time, if you read its documentation, it says that it holds > both a wall clock time and a monotonic time. time.Now() returns a > structure that has both values, but some operations (e.g. time.Parse and > time.Time.UnmarshalJSON) return a time.Time that only has a wall clock > time. t.Round(0) is the canonical way to strip the monotonic time from > a time.Time value t. > > So after t := time.Now(); t2 := t.Round(0), t and t2 represent the same > wall clock time, but compare as different, because the t has both wall > clock and monotonic times, whereas t2 only has wall clock time. > > So your map with key time.Now() has a key with both times. When you > marshal it, the marshalled value only has wall clock time. When you > unmarshal it back to the same map, the unmarshalled time is different > (but represents the same wall clock time) from the existing map key, so > it creates an additional map element with the new key. > > If you create your map with keys that only have wall clock times with > UTC location, as in https://play.golang.org/p/BCB3TAZADB, the > unmarshalled key will match the existing key and overwrite it. If you > remove either .UTC() or .Round(0) or both from that code, you will > notice that the map keys are different, and you end up with two values > in the map after unmarshalling. > > ...Marvin > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: ssh access
On Tue, Nov 28, 2017 at 10:51 AM, tacticianwrote: > using x509.ParsePKCS1PrivateKey I get a structure error: tags don't > match (16 vs 16 length: 117 is Compound:false) > using ssh.NewSignerFromKey I get > > I don't have a password, but do have a passphrase > > What do you mean by "passphrase"? The auth methods are generally a password or public key. Do you mean you have a private key that requires a passphrase? -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: ssh access
On Tuesday, 28 November 2017 15:19:44 UTC, tactician wrote: > > Hi, am trying to access a ubuntu server running Go from a windows machine. > My ubuntu access is via a PuTTy ssh-rsa private/public key. I am now > seeking to access my server from a Go program on windows. All attempts to > cobble together something using ssh that compiles have failed. Any > suggestions. I cannot change my server or client. > using x509.ParsePKCS1PrivateKey I get a structure error: tags don't match (16 vs 16 length: 117 is Compound:false) using ssh.NewSignerFromKey I get I don't have a password, but do have a passphrase -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] ssh access
On Tue, Nov 28, 2017 at 10:19 AM, tacticianwrote: > Hi, am trying to access a ubuntu server running Go from a windows machine. > My ubuntu access is via a PuTTy ssh-rsa private/public key. I am now > seeking to access my server from a Go program on windows. All attempts to > cobble together something using ssh that compiles have failed. Any > suggestions. I cannot change my server or client. > What specific problems are you having? What error messages do you receive when you try to compile? The more detail you provide, the better help you will receive. Whether you intend it or not, questions like the one above sound a lot like "Someone write the code for me for free, because I can't be bothered to learn and your time isn't worth paying for." In the meantime: https://godoc.org/golang.org/x/crypto/ssh -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] ssh access
Hi, am trying to access a ubuntu server running Go from a windows machine. My ubuntu access is via a PuTTy ssh-rsa private/public key. I am now seeking to access my server from a Go program on windows. All attempts to cobble together something using ssh that compiles have failed. Any suggestions. I cannot change my server or client. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps
* Henrik Johansson[171128 07:43]: > But wouldn't unmarshal just overwrite in case of more trivial keys? > > So pointer receivers on the marshaling methods is better. > I think I tried it but something else blew up. While MarshalText can use a value or pointer receiver, it makes no sense to use a value receiver with UnmarshalText. The UnmarshalText method must be able to change the caller's copy of the variable that is to hold the unmarshalled data. As for time.Time, if you read its documentation, it says that it holds both a wall clock time and a monotonic time. time.Now() returns a structure that has both values, but some operations (e.g. time.Parse and time.Time.UnmarshalJSON) return a time.Time that only has a wall clock time. t.Round(0) is the canonical way to strip the monotonic time from a time.Time value t. So after t := time.Now(); t2 := t.Round(0), t and t2 represent the same wall clock time, but compare as different, because the t has both wall clock and monotonic times, whereas t2 only has wall clock time. So your map with key time.Now() has a key with both times. When you marshal it, the marshalled value only has wall clock time. When you unmarshal it back to the same map, the unmarshalled time is different (but represents the same wall clock time) from the existing map key, so it creates an additional map element with the new key. If you create your map with keys that only have wall clock times with UTC location, as in https://play.golang.org/p/BCB3TAZADB, the unmarshalled key will match the existing key and overwrite it. If you remove either .UTC() or .Round(0) or both from that code, you will notice that the map keys are different, and you end up with two values in the map after unmarshalling. ...Marvin -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: HTTP/2 without tls
HTTP2 supports both, decrypt and encrypt ways, however, browsers like Firefox ,Chrome, and IE, doesn't allowed this protocol without security protocols. Ref. http://undertow.io/blog/2015/04/27/An-in-depth-overview-of-HTTP2.html El viernes, 1 de abril de 2016, 16:06:49 (UTC+1), jonathan...@gmail.com escribió: > > Is it possible to use the new 1.6 HTTP/2 support without TLS? I'd like to > use the protocol over a tunnel that is already secure. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps
But wouldn't unmarshal just overwrite in case of more trivial keys? So pointer receivers on the marshaling methods is better. I think I tried it but something else blew up. tis 28 nov. 2017 kl 12:55 skrev roger peppe: > You're seeing that behaviour because you're unmarshaling into the same map > you started with, and encoding/json doesn't zero existing maps before > unmarshaling into them. > > You see two members in the map because time.Now returns a time with a > monotonic time but an unmarshaled time doesn't contain a monotonic time. > > This works OK: https://play.golang.org/p/KJk4iR3D3D > > On 27 November 2017 at 10:53, Henrik Johansson > wrote: > > It seems that time.Time as keys exhibit the same issue: > > https://play.golang.org/p/-_H3ZD6YLG > > > > Is this really intended or a bug? > > > > mån 27 nov. 2017 kl 11:25 skrev Henrik Johansson : > >> > >> There is a discussion here > >> > https://groups.google.com/forum/#!searchin/golang-dev/json$20map/golang-dev/5gSHNrJQpUI/vZGSGRmUrC0J > >> and an issue here: https://github.com/golang/go/issues/12146 > >> > >> At least the issue has an initial example with a value type key > >> > >> mån 27 nov. 2017 kl 11:21 skrev James : > >>> > >>> Think UnmarshalText needs to have a pointer receiver or you'll only be > >>> modifying a copy of the struct > >>> > >>> On 27 November 2017 at 23:13, Henrik Johansson > >>> wrote: > > Hi, > > https://play.golang.org/p/bLiYSsKL_7 > > I have perhaps missed something simple or misunderstood the contract > for > MarshalText/UnmarshalText but it seems to me that it should work it > just > doesn't... :) > > If I uncomment the return of the parse error "BOOM" then I just get a > new "default" key with 3 underscores. > > Anyone knows what I missed? > > Thx, > Henrik > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > > > > -- > > 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. > > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps
James has it right. Try this: https://play.golang.org/p/VQPBwnh4Jn On 27 November 2017 at 10:13, Henrik Johanssonwrote: > Hi, > > https://play.golang.org/p/bLiYSsKL_7 > > I have perhaps missed something simple or misunderstood the contract for > MarshalText/UnmarshalText but it seems to me that it should work it just > doesn't... :) > > If I uncomment the return of the parse error "BOOM" then I just get a new > "default" key with 3 underscores. > > Anyone knows what I missed? > > Thx, > Henrik > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.