[go-nuts] Re: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread snmed
Hi Bryan But the returned uintptr from syscall is as far as i know a pointer to a struct which has been created by the C API, so go runtime won't touch it or do I miss something? Am Freitag, 15. Dezember 2017 00:48:51 UTC+1 schrieb Bryan Mills: > > In this case, the vet tool is correct if

Re: [go-nuts] Github wiki pages publicly editable

2017-12-14 Thread Ivan Borshukov
Forwarding to the mailing list this time. Cheers. On Dec 14, 2017 18:14, "Ivan Borshukov" wrote: Ok, thanks. If so, I want to announce the change that I've maid. It is regarding the rate limiting section [0]. The wiki page states that when the created ticker is Stop-ed,

[go-nuts] Use golang to call the win API

2017-12-14 Thread 流沙
API Address:https://msdn.microsoft.com/en-us/library/ms706716(VS.85).aspx Code: package main // #define WIN32_LEAN_AND_MEAN // #include import ( "fmt" "syscall" "unsafe" "C" ) var ( wlankernal,_ = syscall.LoadLibrary("Wlanapi.dll") wlanhandle,_ =

[go-nuts] Storing types in a map[string]type ?

2017-12-14 Thread jakdept
I'm writing a utility to import/export data into an API. I'd like to be able to accept multiple input/output formats, and support multiple commands. I was going to use kingpin for the flags/commands, and do a type format after that. My plan was to declare an interface with the methods I'm

Re: [go-nuts] Variadic assignable values and covariance

2017-12-14 Thread Jesse McNelis
On Fri, Dec 15, 2017 at 11:08 AM, Ivan Kurnosov wrote: > Jesse, > > what you quoted is an optimisation for the "Otherwise, the value passed is a > new slice of type []T with a new underlying array whose successive elements > ". > > Your quote says: if the final argument is

Re: [go-nuts] Variadic assignable values and covariance

2017-12-14 Thread Ivan Kurnosov
Jesse, what you quoted is an optimisation for the "Otherwise, the value passed is a new slice of type []T with a new underlying array whose successive elements ". Your quote says: if the final argument is assignable - it may be passed as is, without any copy involving. On 15 December 2017 at

[go-nuts] Re: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread 'Bryan Mills' via golang-nuts
In this case, the vet tool is correct if you're making the syscall with Go-allocated memory. The Go runtime is allowed to move values around: the address of a Go variable is only pinned for the duration of the syscall itself. If you've got C-allocated memory (or statically-allocated memory),

[go-nuts] Variadic assignable values and covariance

2017-12-14 Thread Ivan Kurnosov
Why does this code not compile: https://play.golang.org/p/f5fMvO8Ns7 package main import ( "fmt" ) func f(items ...interface{}) { fmt.Println(items) } func main() { f("a", "b", "c") tab := []interface{}{"d"} f("a", "b", "c", tab...) } The spec says: > Otherwise, the value passed is a

Re: [go-nuts] cache for *os.File

2017-12-14 Thread Dave Cheney
It depends a lot on what your application does, but I’d try the trace tool, which should give you execution times of your request and you see its interactions with the garbage collector. For reasonable allocation rates you may find that the gc can collect in the background and not introduce

Re: [go-nuts] Github wiki pages publicly editable

2017-12-14 Thread Jan Mercl
On Thu, Dec 14, 2017 at 5:05 PM Ivan Borshukov wrote: > I've noticed that I'm able to edit the wiki pages on https://github.com/golang/go/wiki and I wonder whether this is intentional. IINM, it's like that from the beginning of the Github repository, so probably

[go-nuts] Github wiki pages publicly editable

2017-12-14 Thread Ivan Borshukov
Hello, I've noticed that I'm able to edit the wiki pages on https://github.com/golang/go/wiki and I wonder whether this is intentional. Cheers, Ivan -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] go generate ignores files ignored for build

2017-12-14 Thread dc0d
IMHO //go:generate ... tasks inside a file marked by // +build ignore should run. Any file that is marked by // +build ignore will be ignored by the compiler. So your code (by putting // +build ignore inside main.go) will generate a compilation error. On Thursday, December 14, 2017 at 2:41:47

Re: [go-nuts] Re: Learning Go: suggestions for code review?

2017-12-14 Thread Ben Hoyt
Yeah, I copied the go/token style there. However, thanks Nigel -- I didn't realize you could do "renaming imports", that's nice. -Ben On Thu, Dec 14, 2017 at 4:35 AM, Jan Mercl <0xj...@gmail.com> wrote: > On Thu, Dec 14, 2017 at 6:27 AM Nigel Tao wrote: > > > As per

Re: [go-nuts] cache for *os.File

2017-12-14 Thread Vasiliy Tolstov
2017-12-14 9:28 GMT+03:00 Dave Cheney : > Does your profiling suggest these allocations are causing latency? > Hmm this is missing part =). How can i understand what causing latency if i use http prof? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this

Re: [go-nuts] go generate ignores files ignored for build

2017-12-14 Thread Jan Mercl
On Thu, Dec 14, 2017 at 11:53 AM dc0d wrote: > What is the reasoning for not executing //go:generate ... comments inside a file, that is excluded from build by // +build ignore? 'ignore' is just a tag like any other: $ cat main.go // +build ignore //go:generate

[go-nuts] go generate ignores files ignored for build

2017-12-14 Thread dc0d
What is the reasoning for not executing //go:generate ... comments inside a file, that is excluded from build by // +build ignore? -- 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,

[go-nuts] Re: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread snmed
Okay I found a way, this seems to work: ca := (*[100]byte) (unsafe.Pointer(certctx.pbCertEncoded))[:certctx. cbCertEncoded] or mm := make([]byte, certctx.cbCertEncoded) for i := uint32(0) ; i < certctx.cbCertEncoded; i++ { mm[i] = *((*byte)(unsafe.Pointer(certctx.pbCertEncoded +

Re: [go-nuts] Re: Learning Go: suggestions for code review?

2017-12-14 Thread Jan Mercl
On Thu, Dec 14, 2017 at 6:27 AM Nigel Tao wrote: > As per https://golang.org/doc/effective_go.html#mixed-caps ALL_CAPS > names are unusual Go style. They are, but token names are often/traditionally all caps and underscores: https://golang.org/pkg/go/token/#Token - in the

[go-nuts] Re: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread snmed
Hi Miki I'm using syscall package and no C import, but maybe it is possible to use this function as well? Am Donnerstag, 14. Dezember 2017 09:18:26 UTC+1 schrieb Miki Tebeka: > > Do you mean > > func C.GoBytes(unsafe.Pointer, C.int) []byte > > ? > > On Thursday, December 14, 2017 at 9:05:32

[go-nuts] Re: python remote objects

2017-12-14 Thread Miki Tebeka
Are you talking about https://pythonhosted.org/Pyro4/ ? It really depends on the serialization format used. If it's json, msgpack or any other language independent format that you can do it. If it's Python specific (marshal, pickle, ...) then you can probably invoke some python code to convert

[go-nuts] Re: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread Miki Tebeka
Do you mean func C.GoBytes(unsafe.Pointer, C.int) []byte ? On Thursday, December 14, 2017 at 9:05:32 AM UTC+2, snmed wrote: > > Hi all > > I'm trying to map a C structure to an equivalent go struct, but I bumped > into a problem with a pointer to byte that is actually an array of bytes. > >