Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread roger peppe
James has it right. Try this: https://play.golang.org/p/VQPBwnh4Jn On 27 November 2017 at 10: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

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread 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 mo

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread Henrik Johansson
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

[go-nuts] Re: HTTP/2 without tls

2017-11-28 Thread jeffersonjnr
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...@gm

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread Marvin Renich
* 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

[go-nuts] ssh access

2017-11-28 Thread tactician
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 suggestio

Re: [go-nuts] ssh access

2017-11-28 Thread Shawn Milochik
On Tue, Nov 28, 2017 at 10:19 AM, 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 som

[go-nuts] Re: ssh access

2017-11-28 Thread tactician
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 > cobbl

Re: [go-nuts] Re: ssh access

2017-11-28 Thread Shawn Milochik
On Tue, Nov 28, 2017 at 10:51 AM, tactician wrote: > 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"

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread Henrik Johansson
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 str

[go-nuts] Re: ssh access

2017-11-28 Thread tactician
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 > co

Re: [go-nuts] Re: ssh access

2017-11-28 Thread Shawn Milochik
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-

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread roger peppe
> 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

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread Henrik Johansson
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 peppe wrote: > > What tripped me up aside from reusing the map in the example was that in > case of errors a value t

Re: [go-nuts] Re: ssh access

2017-11-28 Thread Shawn Milochik
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...@google

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread roger peppe
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 imple

Re: [go-nuts] Problems with JSON Marshal/UnmarshalText aand maps

2017-11-28 Thread Henrik Johansson
Huh... I could have sworn that I tried it. Thx! On Tue, Nov 28, 2017, 5:59 PM roger peppe wrote: > 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 v

[go-nuts] Re: ssh access

2017-11-28 Thread aboukirev
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 mac

Re: [go-nuts] Reading os.Stdin, Unbuffered

2017-11-28 Thread anmol via golang-nuts
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

Re: [go-nuts] chan chan Job per worker vs. single chan Job

2017-11-28 Thread 'Bryan Mills' via golang-nuts
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. Personall

[go-nuts] Re: ssh access

2017-11-28 Thread tactician
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

[go-nuts] Re: ssh access

2017-11-28 Thread tactician
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 r

[go-nuts] Re: ssh access

2017-11-28 Thread aboukirev
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 r

[go-nuts] Re: Reading os.Stdin, Unbuffered

2017-11-28 Thread Robert Solomon
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: Unde

[go-nuts] net/http Server Shutdown does not free up the port upon return

2017-11-28 Thread Albert Tedja
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 := &http.Server{ Addr: fmt.Sprintf(":9000"), } go func() { fmt.Println("hosting...") err := server.Listen

Re: [go-nuts] Re: ssh access

2017-11-28 Thread Marcus Franke
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

Re: [go-nuts] Re: Reading os.Stdin, Unbuffered

2017-11-28 Thread Marcus Franke
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 Solomon sc