Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-20 Thread Dan Kortschak
func bytesToString(b []byte) string { return *(*string)(unsafe.Pointer(&b)) } https://play.golang.org/p/azJPbl946zj On Fri, 2019-09-20 at 13:30 -0700, Francis wrote: > Thanks Ian, that's a very interesting solution. > > Is there a solution for going in the other direction? Although I > e

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-20 Thread Francis
Thanks Ian, that's a very interesting solution. Is there a solution for going in the other direction? Although I excluded it from the initial post, it was only to reduce the size of the discussion. I would also like to implement func BytesToString(b []byte) string { I don't clearly see how to

[go-nuts] [security] Go 1.12.10 and Go 1.13.1 pre-announcement

2019-09-20 Thread Filippo Valsorda
Hello gophers, We plan to issue Go 1.12.10 and Go 1.13.1 on Wednesday, September 25. These are minor releases to fix a security issue. Following our policy at https://golang.org/security, this is the pre-announcement of those releases. Cheers, Filippo on behalf of the Go team -- You received t

Re: [go-nuts] How to mock functions in Go ?

2019-09-20 Thread Sam Whited
On Thu, Aug 1, 2019, at 12:09, Nitish Saboo wrote: > How can we mock a function in Go like os.Hostname() or os.Getwd() > ? Any framework or Library that we can use for mocking the > function calls ? I don't like to think about "mocking" in Go, but I can't provide an alternative term so maybe this

Re: [go-nuts] How to mock functions in Go ?

2019-09-20 Thread Mhd Shulhan
On Fri, 20 Sep 2019, 18:58 Nitish Saboo, wrote: > Tried running you code, it's failing: > > --- FAIL: TestF (0.00s) > test.go:43: got ubuntu, want testing > FAIL > If that's the case I think you should learn about programming in general first, before learning how to mock a function. I beli

Re: [go-nuts] How to mock functions in Go ?

2019-09-20 Thread Nitish Saboo
Tried running you code, it's failing: --- FAIL: TestF (0.00s) test.go:43: got ubuntu, want testing FAIL On Fri, Sep 20, 2019 at 4:07 PM Mhd Shulhan wrote: > > > > On 20 Sep 2019, at 17.21, Nitish Saboo wrote: > > > > I have a function in Go that I want to unit test but that function > co

Re: [go-nuts] How to mock functions in Go ?

2019-09-20 Thread Mhd Shulhan
> On 20 Sep 2019, at 17.21, Nitish Saboo wrote: > > I have a function in Go that I want to unit test but that function contains > os.Hostname().Hence i thought of mocking os.Hostname. > > Example: > > func F(){ > hostname, _ := os.Hostname() > } > > I tried something like this: > > var o

[go-nuts] [ANN] SFTPGo 0.9.2 released with Prometheus metrics support

2019-09-20 Thread Nicola Murino
Hello all, I'm pleased to announce SFTPGo 0.9.2. SFTPGo is a free and open source SFTP Server. Here are the main new features compared to 0.9.1 version: - Prometheus metrics support - Dockerfiles based on Debian and Alpine - Key Exchange algorithms, allowed ciphers and message authentication co

Re: [go-nuts] How to mock functions in Go ?

2019-09-20 Thread Nitish Saboo
I have a function in Go that I want to unit test but that function contains os.Hostname().Hence i thought of mocking os.Hostname. Example: func F(){ hostname, _ := os.Hostname() } I tried something like this: var osHostname = os.Hostname func TestF(t *testing.T) { expected := "testing" defer