[go-nuts] os.Args[0] for program executed by go

2017-06-01 Thread Santhosh Ram Manohar
When I run a go program from the shell, os.Args[0] is the program name. If I invoke the same program using go's exec then os.Args[0] is not the program name, rather its the first argument that I pass. Here is a simple program to show this behavior, installed as gocmd in my $GOPATH/bin func mai

Re: [go-nuts] os.Args[0] for program executed by go

2017-06-01 Thread Santhosh Ram Manohar
On Thursday, June 1, 2017 at 10:45:56 AM UTC-7, Jan Mercl wrote: > > On Thu, Jun 1, 2017 at 7:41 PM Santhosh Ram Manohar > wrote: > > > Args: []string{"self", "selftest"}, > > Here you explicitly pass arsg[0] == "self" and that's w

[go-nuts] gob's interpreted machine

2017-06-03 Thread Santhosh Ram Manohar
>From https://blog.golang.org/gobs-of-data "The first time you encode a value of a given type, the gob package builds a little interpreted machine specific to that data type. It uses reflection on the type to construct that machine, but once the machine is built it does not depend on reflection

[go-nuts] unsafe.Pointer to byte slice

2017-07-08 Thread Santhosh Ram Manohar
hello, This piece of code prints [10 0 0 0] as expected.. func main() { i := 10 p := unsafe.Pointer(&i) intPtr := (*[4]byte)(p) fmt.Println(*intPtr) } But if I convert the unsafe.Pointer to pointer to a byte slice rather than an array of 4 bytes it prints an empt

[go-nuts] Re: unsafe.Pointer to byte slice

2017-07-08 Thread Santhosh Ram Manohar
Dave, On Saturday, July 8, 2017 at 4:09:32 PM UTC-7, Dave Cheney wrote: > An array is a vector of values in memory. A slice is a small struct that > describes an array stored elsewhere in memory. I understand the slice vs array difference. But in this statement, intPtr := (*[]byte)(p) my int

Re: [go-nuts] Re: unsafe.Pointer to byte slice

2017-07-08 Thread Santhosh Ram Manohar
On Sat, Jul 8, 2017 at 7:37 PM, Ian Lance Taylor wrote: > On Sat, Jul 8, 2017 at 6:59 PM, Santhosh Ram Manohar > wrote: > > > > On Saturday, July 8, 2017 at 4:09:32 PM UTC-7, Dave Cheney wrote: > >> > >> An array is a vector of values in memory. A slice is a

Re: [go-nuts] Re: unsafe.Pointer to byte slice

2017-07-09 Thread Santhosh Ram Manohar
On Sun, Jul 9, 2017 at 12:30 AM, Dave Cheney wrote: > As your using the unsafe package your doing things which are not > considered safe by the lanaguge so only imprecise interpretations are > possible. My interpretation is, assuming that next words after p in memory > are zeroed the you have eff