Re: [go-nuts] How to implement a file download service in GRPC

2019-08-01 Thread Rampradeep Nalluri
Thanks Edward, followed this and it worked https://github.com/philips/grpc-gateway-example/blob/master/cmd/serve.go#L91 https://github.com/grpc-ecosystem/grpc-gateway/issues/410 Regards, Ram On Wed, Jul 31, 2019 at 1:26 PM Edward Muller wrote: > https://github.com/grpc-ecosystem/grpc-gateway >

Re: [go-nuts] Re: Contracts Draft: why are method pointers allowed

2019-08-01 Thread Max
I think that a single syntax allowing both pointer receivers and value receivers - with no mechanism to distinguish them - creates unnecessary ambiguity, and in some cases it can concretely be a problem. Consider the following example, adapted from 'math/big.Int`: ``` contract Comparable(T) {

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

2019-08-01 Thread Kyle Butz
You'll want to look into gomock and mockgen. To get started mocking, you'll need an interface, so maybe writing a receiver function encapsulating os.Hostname(), then consuming that with an interface. type OsClient struct {} func (o *OsClient) GetOSHostname() (string, error) { return

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

2019-08-01 Thread kyle . butz
You'll want to check out `gomock` and `mockgen`. You'll need to write an interface to be able to mock, so you may need to write a receiver struct to encapsulate os.Hostname() or whatever you need to mock, then mock your HostnameGetter (surely a better name than that), maybe? type OsClient

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

2019-08-01 Thread Robert Engels
That brings up an interesting idea. A ‘package replace’ during compile. So you request that the os package is replaced by osmock etc. This would allow easy general reuse mocking frameworks without changing the stdlib and all user code. > On Aug 1, 2019, at 8:38 AM, kyle.b...@sezzle.com

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

2019-08-01 Thread Shulhan
On Thu, 1 Aug 2019 05:09:54 -0700 (PDT) Nitish Saboo wrote: > Hi, > > 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 usually does something like these, var getHostname = os.Hostname and

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

2019-08-01 Thread Edward Muller
This can also be done without an interface: https://play.golang.org/p/fgRX2nXIxn0 In ^ example “Thing” would be the type you are working on, with functional options (https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

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

2019-08-01 Thread Nitish Saboo
Hi, 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 ? Thanks, Nitish -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Re: Contracts Draft: why are method pointers allowed

2019-08-01 Thread Steven Blenkinsop
On Thu, Aug 1, 2019 at 6:35 AM, Max wrote: > Thus it would require 'T' to be a pointer - namely '*big.Int' - to match. > It would mean that the receiver itself of the contract 'T Cmp(other T) > int' is a pointer. Is it a case allowed by contracts? > Yes, this is something which is supported be