You have to use a temporary to swap the values:
tmp := a.Interface()
a.Set(b)
b.Set(reflect.ValueOf(tmp))
*Josh Humphries*
jh...@bluegosling.com
On Mon, Jul 31, 2017 at 10:18 AM, eZio Pan <eziopa...@gmail.com> wrote:
> Hello,
> I want to build a "univers
vice versa, is disallowed? We're already using the
unsafe package, so I can't think of a clear reason to prevent this.
----
*Josh Humphries*
jh...@bluegosling.com
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this grou
On Fri, Aug 11, 2017 at 6:22 PM, Ian Lance Taylor <i...@golang.org> wrote:
> On Fri, Aug 11, 2017 at 2:51 PM, Josh Humphries <jh...@bluegosling.com>
> wrote:
> >
> > It is possible to extract a map's actual value/address if it is stored in
> >
Although that solution creates a heap-allocated tmp for every element in
the slice. Using an interface, the value will be inlined instead of
heap-allocated if it fits without boxing (so most primitive types and
pointer types won't need heap allocation).
*Josh Humphries*
jh...@bluegosling.com
On Tue, Aug 1, 2017 at 11:44 AM, roger peppe <rogpe...@gmail.com> wrote:
> On 1 August 2017 at 13:57, Josh Humphries <jh...@bluegosling.com> wrote:
> > Although that solution creates a heap-allocated tmp for every element in
> the
> > slice. Using an interface, the
On Tue, Aug 1, 2017 at 2:43 PM, roger peppe <rogpe...@gmail.com> wrote:
> On 1 August 2017 at 19:33, Josh Humphries <jh...@bluegosling.com> wrote:
> > On Tue, Aug 1, 2017 at 11:44 AM, roger peppe <rogpe...@gmail.com> wrote:
> >>
> >>
implement our own cancellation propagation
-- like a goroutine that will stop the server(s) when the root context gets
cancelled.
I'm curious how others tackle these kinds of concerns.
*Josh Humphries*
jh...@bluegosling.com
--
You received this message because you are subscribed to the
goroutines have completed
(e.g. cancel the context and then await, provided you've added to the wait
group for each task and each one marks their work as done on completion).
*Josh Humphries*
jh...@bluegosling.com
On Fri, Aug 18, 2017 at 5:19 PM, <bill.war...@talentinc.com> wrote:
> Thank
This is a problem that is usually solved in Go with code generation. You
would use a go:generate directive to generate implementations for an
interface of interest.
Something like java.lang.reflect.Proxy in Go would be very cool though.
*Josh Humphries*
jh...@bluegosling.com
On Tue, Jun 20
-of-week by defining the constants in order. With strings, you have to
use a custom compare function that acts on string names (ick).
*Josh Humphries*
jh...@bluegosling.com
On Sun, Oct 15, 2017 at 4:13 PM, <m...@inanc.io> wrote:
> Is it anything wrong just assigning string values t
You can't convert between maps with different types of keys or values. So
you have to copy the map into one with the correct target type:
https://play.golang.org/p/qmD2pypNbj
*Josh Humphries*
jh...@bluegosling.com
On Mon, Aug 21, 2017 at 10:48 AM, Tong Sun <suntong...@gmail.com>
at you are doing, and
thus it requires you to be more explicit in both client and server code to
make it work.
*Josh Humphries*
jh...@bluegosling.com
On Wed, Nov 15, 2017 at 3:43 PM, Albert Tedja <nicho.te...@gmail.com> wrote:
> Thank you for the links.
>
> I am still somewhat di
a factory
method that takes a function and adapts it to the interface. And then the
value can be used both to invoke the logic (by calling the one method of
the interface) and for inspecting its concrete type and value.
*Josh Humphries*
jh...@bluegosling.com
On Wed, Nov 22, 2017 at 8:26 AM
a function that does
not capture a method receiver, and then your interpretation of whatever you
read using unsafe will likely cause memory corruption and/or a program
crash.
*Josh Humphries*
jh...@bluegosling.com
On Wed, Nov 22, 2017 at 8:46 PM, Hoping White <baihaop...@gmail.
rfaces
(this is a common pattern in Go, to make sure any change to a concrete type
to make it *not* implement a particular interface result in a compile-time
error).
*Josh Humphries*
jh...@bluegosling.com
On Mon, Nov 20, 2017 at 4:27 PM, 'Paulo Matos' via golang-nuts <
golang-nuts@googleg
an example of this erroneous behavior.
Demonstrations of these issues:
https://play.golang.org/p/Qu0irn2rCF
I am guessing I should just file a bug in a Github issue, but wanted to
first check to see if this, somehow, might be expected behavior. (And if
so, to learn why.)
*Josh Humphries*
jh
The syntax you are looking for is:
max(test.vals...)
The ellipsis indicates that the var args are the *contents* of the slice,
as opposed to trying to pass the slice as if it were just a single element
of the var args.
*Josh Humphries*
jh...@bluegosling.com
On Wed, May 23, 2018 at 7:09
("unsupported type: %T", e))*
*}*
*}*
----
*Josh Humphries*
jh...@bluegosling.com
On Thu, Jan 4, 2018 at 10:24 AM, Tong Sun <suntong...@gmail.com> wrote:
> I need a data struct / solution that I can store mixed data-types into an
> array. How to architect that?
>
in Wikipedia -- likes more like its a
related pattern: the decorator (sometimes known as the interceptor pattern).
*Josh Humphries*
jh...@bluegosling.com
On Fri, Feb 2, 2018 at 12:03 PM, <matthewju...@gmail.com> wrote:
> I’m looking at patterns summarized on Wikipedia from “Design Patterns:
&
d the
rest of your code).
----
*Josh Humphries*
jh...@bluegosling.com
On Thu, Feb 1, 2018 at 6:31 AM, s2gatev <m...@s2gatev.com> wrote:
> Hey there!
>
> I'm trying to convert an AppEngine flexible setup to standard environment.
> I hit a problem with a piece of code that depends on
to produce. (For example, the ASM
<http://download.forge.objectweb.org/asm/asm4-guide.pdf> library for Java.)
>
> -rob
>
>
> On Thu, Feb 8, 2018 at 2:14 PM, Josh Humphries <jh...@bluegosling.com>
> wrote:
>
>> FWIW, it looks like someone else has gone through this
FWIW, it looks like someone else has gone through this exercise:
https://github.com/tmrts/go-patterns
*Josh Humphries*
jh...@bluegosling.com
On Fri, Feb 2, 2018 at 12:03 PM, <matthewju...@gmail.com> wrote:
> I’m looking at patterns summarized on Wikipedia from “Design Patterns:
&
On Wed, Feb 7, 2018 at 5:45 PM, roger peppe wrote:
> As someone totally unfamiliar with the GoF patterns, hre's my take.
> I looked at the wikipedia articles and tried to work out what
> problem I thought the pattern was trying to address and then
> wrote some Go code to do
On Thu, Feb 22, 2018 at 4:56 AM, Steven Hartland
wrote:
> On 22/02/2018 09:46, andrewchambe...@gmail.com wrote:
>
> Just a list of things I like about Go, thanks everyone for the hard work:
>
> snip...
>
> Minor things that could be improved in order of importance:
>
> -
to int).
*Josh Humphries*
jh...@bluegosling.com
On Mon, Jan 22, 2018 at 5:58 PM, Dan Kortschak <
dan.kortsc...@adelaide.edu.au> wrote:
> This is sort of surprising though: https://play.golang.org/p/mjfkzIqAo_b
>
> On Mon, 2018-01-22 at 10:20 -0800, C Banning wrote:
> &
d *P.T
*T// conflicts with embedded field T and *P.T
*P.T // conflicts with embedded field T and *T
}
So it is possible that this is not a bug in the encoding/json package but
in the compiler.
*Josh Humphries*
jh...@bluegosling.com
On Mon, Jan 22, 2018 at 7:28 PM, Josh Humphri
(based on the type
alias names), but the field's type is simply int (which is not exported due
to starting with lower-case letter).
*Josh Humphries*
jh...@bluegosling.com
On Mon, Jan 22, 2018 at 3:12 AM, 'Axel Wagner' via golang-nuts <
golang-nuts@googlegroups.com> wrote:
> On Mo
ames
are upper-cased. I think this is either a bug in reflect -- which should
set StructField.PkgPath to "" since the field name is exported -- OR a bug
in the compiler which should complain that there are three fields whose
resolved name appears to be the unexported identifier "int&
n when using standard Kubernetes services (when using gRPC for
>> server-to-serve communication), as kubedns resolves a service name into a
>> single virtual IP. I'm not sure if the current state of the world regarding
>> TCP load balancers and the grpc-go project, but if it's still
state of the world regarding TCP load
balancers and the grpc-go project, but if it's still an issue and you run
services in Kubernetes, you can use a 3rd party resolver:
https://github.com/sercand/kuberesolver.
*Josh Humphries*
jh...@bluegosling.com
On Wed, Oct 17, 2018 at 2:13 AM wrote
onment. But you can also use a --plugin flag to protoc to
tell it exactly where the plugin binary lives.
*Josh Humphries*
jh...@bluegosling.com
On Sun, Nov 18, 2018 at 4:57 PM Tharaneedharan Vilwanathan <
vdhar...@gmail.com> wrote:
> Hi All,
>
> I have a minor question. When I run
On Fri, Nov 30, 2018 at 8:50 AM Michel Levieux
wrote:
> Hi guys,
>
> I've been trying to find examples of cases where it is complicated to
> structure the project because circular imports are forbidden, but I can't
> find something simple that I can show you. The thing is when I've been
>
On Wed, Dec 5, 2018 at 12:16 PM Burak Serdar wrote:
> On Wed, Dec 5, 2018 at 10:12 AM Mark Volkmann
> wrote:
> >
> > I can get a reflect.Type for a variable with the following: myType :=
> reflect.TypeOf(myVariable)
> >
> > How can I get a reflect.Type for a type I have defined?
> > For
On Fri, Jan 11, 2019 at 5:59 PM Xinhu Liu wrote:
> Hi Ian,
>
> thanks for your reply.
>
> After reading and experimenting a lot I think I understand the slight
> differences between nil and interface{} with nil value.
>
> The only thing I find confusing is that interface{}(nil) == nil returns
>
On Wed, Sep 12, 2018 at 9:05 AM robert engels wrote:
> Hi, I am adding a remote component to my github.com/robaho/keydb project
> and decided to use gRPC.
>
> I’ve reviewed the docs, and it appears to want to be stateless - which
> given the nature of Google makes sense.
>
> But for something
On Tue, Jan 22, 2019 at 8:33 AM wrote:
> Hi, we have the same problem of OP.
> But, in the Chris's playground there could be an error, indeed if the
> consumer
> runs slower of the producer the program ends in a deadlock.
>
> To force this behavior just add a time.Sleep() after the foor loop in
36 matches
Mail list logo