Re: [go-nuts] Embedding an interface with a function type

2024-02-06 Thread Victor Manuel Giordano
Thanks El mar, 6 feb 2024 a las 12:05, Ian Lance Taylor () escribió: > On Tue, Feb 6, 2024 at 6:43 AM Victor Manuel “Vitu” Giordano > wrote: > > > > I'm wondering why the language allow me to write something like this: > > > > type IncFunc func(a int) int > > > > type Incrementor interface { > >

Re: [go-nuts] Embedding an interface with a function type

2024-02-06 Thread Ian Lance Taylor
On Tue, Feb 6, 2024 at 6:43 AM Victor Manuel “Vitu” Giordano wrote: > > I'm wondering why the language allow me to write something like this: > > type IncFunc func(a int) int > > type Incrementor interface { > IncFunc // <-- THIS is allowed > IncQuantity() int > } > > (RTR example here) > > I don'

[go-nuts] Embedding an interface with a function type

2024-02-06 Thread Victor Manuel “Vitu” Giordano
Hi Goperhs! How you doing? Hope just fine! I'm wondering why the language allow me to write something like this: type IncFunc func(a int) int type Incrementor interface { IncFunc *// <-- THIS is allowed* IncQuantity() int } (RTR example here ) I don't get how

[go-nuts] Embedding shared libraries into gomobile archive

2023-01-18 Thread 'Vitaliy Vlasov' via golang-nuts
Hi all! I've got a golang project that uses cgo to interface with an external C library. So golang builds depend on that library's *.h and *.so files. Is there a way to tell `gomobile bind` to embed these external shared libraries into generated Android AAR or iOS Framework files? Thanks. --

Re: [go-nuts] Embedding any (empty interface) in a struct in Go

2022-10-26 Thread 'Axel Wagner' via golang-nuts
On Wed, Oct 26, 2022 at 9:17 PM sick...@gmail.com wrote: > Consider a scenario where you want to embed an error within any type of > variable. > > This can be achieved by embedding any in a struct and it seems to be a > valid syntax in Go 1.9. > type WithError struct { > any >

[go-nuts] Embedding any (empty interface) in a struct in Go

2022-10-26 Thread sick...@gmail.com
Consider a scenario where you want to embed an error within any type of variable. This can be achieved by embedding any in a struct and it seems to be a valid syntax in Go 1.9. type WithError struct { any err error } func main() { a := WithError{ any: 5,

Re: [go-nuts] Embedding playground snippets in gist-like way

2022-05-11 Thread Ggicci T'ang
I've implemented a simple js sdk goplay to connect to a reverse proxy to the official go playground service at go.dev/play. Now it seems works smoothly. If you are interested in this, I'd like to share it with you: ggicci.me/goplay. On Tuesday, June 2, 2015

[go-nuts] embedding files in tests

2021-06-01 Thread Manlio Perillo
When a file is embedded in a test file, will the file be embedded only in the test binary? The documentation says nothing about this case, but the data from go list seems to confirm that the file is only embedded in the test binary. Thanks Manlio -- You received this message because you are su

Re: [go-nuts] embedding

2020-09-28 Thread Michał Pawełek
Thanks ! poniedziałek, 28 września 2020 o 19:00:10 UTC+2 bbse...@gmail.com napisał(a): > On Mon, Sep 28, 2020 at 10:55 AM Michał Pawełek > wrote: > > > > https://play.golang.org/p/CBuzITRmTiP > > > > Why isn't T1 allowed to pass to f ? > > func f requires an argument of type T. You cannot pass

Re: [go-nuts] embedding

2020-09-28 Thread burak serdar
On Mon, Sep 28, 2020 at 10:55 AM Michał Pawełek wrote: > > https://play.golang.org/p/CBuzITRmTiP > > Why isn't T1 allowed to pass to f ? func f requires an argument of type T. You cannot pass a value of type T1. However, T1 has T embedded in it, so you can pass: f(t1.T) > > -- > You received t

[go-nuts] embedding

2020-09-28 Thread Michał Pawełek
https://play.golang.org/p/CBuzITRmTiP Why isn't T1 allowed to pass to f ? -- 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.

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Tong Sun
On Sunday, January 14, 2018 at 6:01:39 AM UTC-5, Jan Mercl wrote: > > On Sun, Jan 14, 2018 at 5:37 AM > wrote: > > > I have a parent/child class ... > > You don't. No classes, no parents, no children. You need to make your > design work with Go. In most cases you cannot make Go work like languag

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread 'Axel Wagner' via golang-nuts
I'm not sure I understand the question correctly. You *can* use the variable in the switch block (i.e. in the indvidual cases). But maybe these two quotes from the spec answer your question nevertheless: Quote 1 : Each clause in a "switch" or "select" statement

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Tong Sun
Thanks Axel. The examples make it very clear. https://play.golang.org/p/fSLw3R_tujV So what's the differences between the implicit block around the switch statement and if statement (or loop-variables)? -- - the variables defined in the if statement's implici

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread 'Axel Wagner' via golang-nuts
Go does not allow declaring the same identifier in one scope twice, but there is an implicit block around the switch statement. This is the same mechanism by which loop-variables are scoped. So it is functionally equivalent to this

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Tong Sun
Thanks Axel. One question, how come the following would even compile? func setf(p Parenter) { switch p := p.(type) { case Child: p.Attr2 = "foo" case Child2: p.Attr3 = "foo" } } I.e., in setf(), we have two `p`s with different types, how can it be even possible with Go? -- I thought Go

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread 'Axel Wagner' via golang-nuts
As others have mentioned, the lingo is wrong (there is no inheritance in Go), but this is how you can make your specific code work as intended: https://play.golang.org/p/LVE8gFDtAM7 On Sun, Jan 14, 2018 at 3:08 PM, wrote: > Use the interface type assertion or type switch: https://tour.golang. >

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread matthewjuran
Use the interface type assertion or type switch: https://tour.golang.org/methods/16 Matt On Sunday, January 14, 2018 at 5:01:39 AM UTC-6, Jan Mercl wrote: > > On Sun, Jan 14, 2018 at 5:37 AM > wrote: > > > I have a parent/child class ... > > You don't. No classes, no parents, no children. You ne

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Jan Mercl
On Sun, Jan 14, 2018 at 5:37 AM wrote: > I have a parent/child class ... You don't. No classes, no parents, no children. You need to make your design work with Go. In most cases you cannot make Go work like languages supporting classes and inheritance. -- -j -- You received this message b

[go-nuts] embedding - Access child struct elements by type casting

2018-01-13 Thread raghu . maddali
Hello, I have a parent/child class and a method that accepts parameters as below. How do I type cast to parent/child in setf and access its elements. t := reflect.ValueOf(p).Elem().Type() returns types as Parenter for setf type Parenter interface { GetParent() interface{} } type Parent

[go-nuts] Embedding SWI Prolog in Go

2017-05-27 Thread Tieson Molly
I am curious if there are any projects out there that have embedded a SWI Prolog engine in Go via cgo? Best regards, Ty -- 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 e