[go-nuts] Re: cgo and Python as a shared library

2022-11-23 Thread Deiter
m the linker. Thanks. On Wednesday, November 23, 2022 at 6:48:25 PM UTC-8 Deiter wrote: > macOS: 12.5.1 > go: go1.19.3 darwin/amd64 > > I'm having trouble building a go module that uses Python as a shared > library. > > This code works: > ... > package main &

[go-nuts] cgo and Python as a shared library

2022-11-23 Thread Deiter
macOS: 12.5.1 go: go1.19.3 darwin/amd64 I'm having trouble building a go module that uses Python as a shared library. This code works: ... package main // #include import "C" import "fmt" func main() { fmt.Println("Max float value of float is", C.FLT_MAX) } ... $ go run . Max float value of

[go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread Deiter
The reflect package provides the SetMapIndex method for updating elements in a map that are represented by a reflect.Value type, but I don’t see an equivalent for array/slice. The sample app (link provided below) includes an example of map that’s been made accessible through a a reflect.Valu

[go-nuts] Methods and pointer type receivers

2021-02-27 Thread Deiter
Go: go1.15.8 darwin/amd64 OS: MacOS 11.2.1 The program here includes a type and a method that acts on that type: type Prefix struct { prefix string } func (rec *Prefix) outputString(s string) { fmt.Printf("%v: %v\n", rec.prefix, s) } Very straigh

[go-nuts] Using ellipses in a variadic function call

2021-02-27 Thread Deiter
Go: go1.15.8 darwin/amd64 OS: MacOS 11.2.1 The program here includes a function with variadic arguments: func outputStrings(strings …string) Individual strings can be passed specifically: outputStrings("foo", "bar") You can also use an ellipses to

[go-nuts] Resolving type ambiguity w/ functions that return an interface

2021-02-27 Thread Deiter
Go: go1.15.8 darwin/amd64 OS: MacOS 11.2.1 It makes sense to me that a function can have arguments that are interfaces - so long as the argument provides the methods that the function requires, it will be happy. However, I’m having a difficult time understanding functions that return an interfa