Re: [go-nuts] Go Tour ok?

2020-04-21 Thread Anssi Porttikivi
Yes, exactly that happened, your bug reporting is better than mine. ;-) On Tuesday, 21 April 2020 21:08:11 UTC+3, Marvin Renich wrote: > > * Anssi Porttikivi > [200421 08:57]: > > I had to run the Go Tour locally, because the web version gives me odd > > "timed out" and "build failed" (with no r

Re: [go-nuts] Re: Is the following funciton always safe to convert a string to a slice?

2020-04-21 Thread Ian Lance Taylor
On Tue, Apr 21, 2020 at 8:17 AM T L wrote: > > And is the runtime.KeepAlive call in the following program essential to keep > the correctness? > > package main > > import ( > "fmt" > "unsafe" > "reflect" > "runtime" > ) > > func main() { > a := [6]byte{'G', 'o', 'o', 'g', 'l',

Re: [go-nuts] Is the following funciton always safe to convert a string to a slice?

2020-04-21 Thread Ian Lance Taylor
On Tue, Apr 21, 2020 at 6:49 AM T L wrote: > > func String2ByteSlice(str string) (bs []byte) { > strHdr := (*reflect.StringHeader)(unsafe.Pointer(&str)) > sliceHdr := (*reflect.SliceHeader)(unsafe.Pointer(&bs)) > > // Is it possible that the str value is allocated on stack > // and

Re: [go-nuts] Gollvm, some questions

2020-04-21 Thread Ian Lance Taylor
[ +Than McIntosh +Cherry Zhang ] On Tue, Apr 21, 2020 at 4:19 PM wrote: > > I am interesting in gollvm project and would like to ask some questions about > gollvm. > 1) Are there any special blog or news feed dedicated to gollvm? > 2) How to choose version of llvm for gollvm? For example, is it

[go-nuts] Gollvm, some questions

2020-04-21 Thread sidertatver
I am interesting in gollvm project and would like to ask some questions about gollvm. 1) Are there any special blog or news feed dedicated to gollvm? 2) How to choose version of llvm for gollvm? For example, is it possible to take llvm-9.0 for current version of gollvm? What is the algorithm of

[go-nuts] Re: Equivalent of os.Args but on custom input

2020-04-21 Thread ben.hoyt via golang-nuts
There's also Google's shlex package: https://pkg.go.dev/github.com/google/shlex?tab=doc Incidentally, on Windows Go has to do this manually on startup. See commandLineToArgv in https://golang.org/src/os/exec_windows.go -Ben On Tuesday, April 21, 2020 at 4:27:41 AM UTC+12, Michał Łowicki wrote:

[go-nuts] Re: Packet parsing in Go

2020-04-21 Thread Manlio Perillo
On Tuesday, April 21, 2020 at 6:08:22 PM UTC+2, Rakesh K R wrote: > > Hi, > I am new to Go and I am trying to parse the network packets received. > In C, we used to typecast this array of uint8_t to predefined structure. > Is there a way I can do this similarly in Go? or any better approach to do

Re: [go-nuts] Packet parsing in Go

2020-04-21 Thread Rakesh K R
Application is supposed to run on docker and base image for this docker is fixed. i.e ubuntu 18 always. Looks like I need to parse slice of bytes one by one. gopacket has support for packet parsing but it dont support dlna packets. Any pointers apart from this will be helpful On Tue, 21 Apr 2020

Re: [go-nuts] Packet parsing in Go

2020-04-21 Thread Jan Mercl
On Tue, Apr 21, 2020 at 6:08 PM Rakesh K R wrote: > In C, we used to typecast this array of uint8_t to predefined structure. Go has no casts. Regardless, one can do something similar using unsafe. But then - how it's planned to deal with the situation when the machine endianess does not match th

Re: [go-nuts] Go Tour ok?

2020-04-21 Thread Marvin Renich
* Anssi Porttikivi [200421 08:57]: > I had to run the Go Tour locally, because the web version gives me odd > "timed out" and "build failed" (with no reason) errors > indeterministically... Is it just me? I was having the same trouble earlier today. The build (or run) was timing out, and the t

[go-nuts] thread local storage of C library from go application

2020-04-21 Thread Tamás Gulácsi
Lock C-calling goroutines to their threads with runtime LockOSThread and communicate with them through channels. -- 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

[go-nuts] thread local storage of C library from go application

2020-04-21 Thread Pavan
Hi, We are using C library which has some data stored per thread in thread-local-storage. go application is using this library. as threads terminate, TLS storage was freed but now with go application, the TLS seems invalid or inconsistent. I mean 2 go routines can be running under same pthrea

[go-nuts] Re: x509.ParsePKCS1PrivateKey fails to parse key generated with openssl

2020-04-21 Thread Trevor Gevers
I had to do the same thing in order to create a JWT for salesforce integration and the caveat was that the pem file was encoded, this worked for me, notice as stated above pem.Decode() is needed. package auth import ( "crypto/x509" "encoding/pem" "fmt" jwt "githu

[go-nuts] Re: Problem running tour on local machine (Program exited: signal: killed)

2020-04-21 Thread youngwoo
I went through same problem and solved it thanks to this post. On Tuesday, January 28, 2020 at 12:21:04 AM UTC+9, isaac@gmail.com wrote: > > Sorry for the false alarm -- I found a workaround (building the tour > locally) which seems to solve my problem here: > https://github.com/golang/tou

[go-nuts] What is the current state of formatting and stack trace info for error values post 1.13 release?

2020-04-21 Thread pankaj pipada
As per comment: https://github.com/golang/go/issues/29934#issuecomment-489682919 Go 1.13 shipped without stack trace info and error formatting interfaces. The comment also indicates that this was supposed to be revisited in Go 1.14. - Have there been any additions on this front? - If not, are

[go-nuts] Packet parsing in Go

2020-04-21 Thread Rakesh K R
Hi, I am new to Go and I am trying to parse the network packets received. In C, we used to typecast this array of uint8_t to predefined structure. Is there a way I can do this similarly in Go? or any better approach to do this in Go? i.e. I need to parse the packet to store them to respective l2/

[go-nuts] Re: x509.ParsePKCS1PrivateKey fails to parse key generated with openssl

2020-04-21 Thread James Mackerel
Hi, Please take a look at . If this is your code to parse your private key: f, err := os.Open(file) > if err != nil { > return nil, err > } > buf, err := ioutil.ReadAll(f) > if

[go-nuts] Re: Is the following funciton always safe to convert a string to a slice?

2020-04-21 Thread T L
And is the runtime.KeepAlive call in the following program essential to keep the correctness? package main import ( "fmt" "unsafe" "reflect" "runtime" ) func main() { a := [6]byte{'G', 'o', 'o', 'g', 'l', 'e'} bs := []byte("Golang") hdr := (*reflect.SliceHeader)(unsa

[go-nuts] Re: Go Tour ok?

2020-04-21 Thread Brian Candler
On a quick test of a few pages it works for me - but that doesn't prove anything one way or the other. If you try it again, and it still fails, have a look in your browser's console to see what requests it was making and what response it got (HTTP status code, any error message in the body). T

[go-nuts] Is the following funciton always safe to convert a string to a slice?

2020-04-21 Thread T L
func String2ByteSlice(str string) (bs []byte) { strHdr := (*reflect.StringHeader)(unsafe.Pointer(&str)) sliceHdr := (*reflect.SliceHeader)(unsafe.Pointer(&bs)) // Is it possible that the str value is allocated on stack // and the stack grows at this moment, so the address valu

[go-nuts] Go Tour ok?

2020-04-21 Thread Anssi Porttikivi
I had to run the Go Tour locally, because the web version gives me odd "timed out" and "build failed" (with no reason) errors indeterministically... Is it just me? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group a

Re: [go-nuts] memory leak of C functions with pprof WriteHeapProfile

2020-04-21 Thread Pavan
Thanks for the link. even valgrind gives good info on go binary for C functions. Regards On Tuesday, April 21, 2020 at 4:01:07 AM UTC+5:30, robert engels wrote: > > see > https://www.gnu.org/software/libc/manual/html_node/Allocation-Debugging.html > for > C memory debugging > > On Apr 20, 2

Re: [go-nuts] Best design to copy a struct

2020-04-21 Thread Kevin Chadwick
On 2020-04-21 10:09, Thomas S wrote: >> But most of the time for getting a copy of a struct, I do something like >> this : >> >> func (re Regexp) Copy() *Regexp { >>    119 return &re >>    120  } If you are just trying to shallow copy a struct then I find this pointer usage distasteful. Far mor

Re: [go-nuts] Best design to copy a struct

2020-04-21 Thread Thomas S
I did not know this stylistic guideline. Thank you Ian ! Le mardi 21 avril 2020 00:42:39 UTC+2, Ian Lance Taylor a écrit : > > On Mon, Apr 20, 2020 at 1:56 PM Thomas S > > wrote: > > > > In regexp package, the "copy" function is implemented like this : > > > > func (re *Regexp) Copy() *Regex