Re: [go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread Ayan George
Rob Pike wrote: > Let me ask, because I'm genuinely curious: Why does it matter? The labels > we apply to things do not affect their function. Perhaps it affects how we > think about them. Is that it? > Yes -- that's it exactly! I think the amount of hair-splitting over what is an object

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread Ayan George
Great points. For me this is as much if not more of a communications issue than a technical one. It seems like the definition of what an OO language is broad enough that we could go on forever about if Go is one. The language developers can also choose to declare what it is meant to be

[go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread Ayan George
The Go FAQ begins the answer to the question, "Is Go an object-oriented language," with, "yes and no." https://go.dev/doc/faq#Is_Go_an_object-oriented_language The section goes on to say that Go has methods but there is no type hierarchy. I guess those are the yes and no. But I feel like

[go-nuts] what is the origin of Go's reference time system?

2022-10-26 Thread Ayan George
I'm really impressed by the simplicity of Go's time formatting and parsing mechanisms -- particularly when compared with strftim(). Does anyone know the origin or history of it? Is there a precedent for using reference layouts that include string like 2006, January, etc.? Do other languages

[go-nuts] Re: Using log Package with log.Lshortfile Flag

2018-04-11 Thread Ayan George
On Wednesday, April 11, 2018 at 5:31:55 AM UTC-4, Kaveh Shahbazian wrote: > > The code resides here . > > The output from the program is: > > NaClMain [ info ] 23:00:00 main.go:13: main.main started > NaClMain [ info ] 23:00:00 main.go:13: main.compute1

Re: [go-nuts] Using reflect to call functions on struct members

2018-01-18 Thread Ayan George
On 01/18/2018 01:28 PM, Boone Severson wrote: > Hi, > > I've got structs containing custom types. I'm hoping to use reflect > to create some fairly generic code to Validate() every field of a > struct based on its type, but I can't seem to get the code right. Is > this possible? I've set up a

Re: [go-nuts] Go as your first language

2018-01-16 Thread Ayan George
On 01/16/2018 02:10 AM, James Pettyjohn wrote: > > Are there tracks of knowledge to take someone from 0 to understanding > baseline knowledge? > > And from there through taking them to a professional grade standard? > I think "Introducing Go" is a great book for someone relatively new to

Re: [go-nuts] http.FileServer: how to serve static files requested from different domains?

2018-01-14 Thread Ayan George
On 01/13/2018 11:26 PM, Constantine Vassilev wrote: > Here is how I implemented it: > Well -- just to be clear: I think my solution is wrong. I didn't understand how http.ServeMux worked: https://golang.org/pkg/net/http/#ServeMux Andy Balholm pointed out that http.Handle() can accept a

Re: [go-nuts] http.FileServer: how to serve static files requested from different domains?

2018-01-10 Thread Ayan George
On 01/09/2018 02:34 PM, Andy Balholm wrote: > Try: > > http.Handle(“domain1.com/assets/", http.StripPrefix("/", > http.FileServer(http.Dir(*webrootdomain1 > http.Handle(“domain2.com/assets/", http.StripPrefix("/", > http.FileServer(http.Dir(*webrootdomain2 > Wow! Reading is

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread Ayan George
On 01/09/2018 04:45 PM, Ian Lance Taylor wrote: > On Tue, Jan 9, 2018 at 1:02 PM, Jim Bishopp > wrote: >> >> Has there ever been a discussion about allowing new identifiers and >> selectors in short variable declarations? >> >> var a struct { x int } b, a.x := 1, 2 >>

Re: [go-nuts] http.FileServer: how to serve static files requested from different domains?

2018-01-09 Thread Ayan George
Constantine Vassilev wrote: > > I have web server serving requests from two domains: domain1.com and > domain2.com > The assets directories are different for the two domains. > > webrootdomain1/assets > and > webrootdomain2/assets > > How to make the handler for assets to

Re: [go-nuts] Using database/sql in a web application

2018-01-05 Thread Ayan George
On 01/05/2018 10:16 AM, Manlio Perillo wrote: > Recently I have developed a few web applications in Go, using a > PostgreSQL database, but I have yet understand the best way to use > the database/sql package. > I don't know how you're serving web pages but I typically use net/http. This also

Re: [go-nuts] fetching URLs Concurrently

2017-11-13 Thread Ayan George
On 11/13/2017 04:10 AM, 2891132l...@gmail.com wrote: > for range os.Args[1:] { >   fmt.Println(<-ch) >      } >      fmt.Printf("%.2fs elasped\n", time.Since(start).Seconds()) > } If I understand correctly, you want fetch() to get each URL twice but you only read from the 'ch'

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-03 Thread Ayan George
On 11/03/2017 05:23 AM, oju...@gmail.com wrote: > Could somebody please point me to any example of comparing an > interface to nil, in production code? Thanks. > Does checking if a variable of type error is nil count? -ayan -- You received this message because you are subscribed to the

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-01 Thread Ayan George
On 11/01/2017 07:18 AM, oju...@gmail.com wrote: > Ayan, imagine I am part of a development team. In our program I have a > pointer r: > > r *myType > > My variable r can be nil, because that is a valid situation. It is used > in dozens of places, like this: > > if r != nil { >    

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-01 Thread Ayan George
On 10/31/2017 12:42 PM, oju...@gmail.com wrote: > Today you can't, Ayan. > Right -- I understand that. I'm asking how would you propose Go do that? What changes would you make to fix this? I'm asking: If you claim Go is fundamentally broken in this way, how would you fix it? -ayan --

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-10-31 Thread Ayan George
On 10/31/2017 10:25 AM, oju...@gmail.com wrote: > Not being able to test for a nil interface is a Go language bug. > Just curious: How would you do this without type assertion or reflection? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Is the reflect package performant?

2017-10-27 Thread Ayan George
On 10/27/2017 04:32 AM, go-question wrote: > I'm accustomed to avoiding reflection in other languages due to > performance concerns, is that unfounded with Go's reflect package? > There is some cost to using the reflect package but I don't think that cost is unusually high. I think whether

Re: [go-nuts] TCP writes without a corresponding read?

2017-10-22 Thread Ayan George
On 10/22/2017 06:06 AM, Ayan George wrote: > > > buf := make([]byte, 0, 20) > Sorry -- I meant: buf := make([]byte, 20) -- 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] TCP writes without a corresponding read?

2017-10-22 Thread Ayan George
On 10/22/2017 04:50 AM, Matt Mueller wrote: > Hey everyone! > > This question cropped up while testing. It's 2 related questions: > > *1. Why am I able to write to without accepting a connection?* > As I understand it, by the time you accept() a connection, the TCP stream has already been

Re: [go-nuts] godoc only indexes packages in GOROOT?

2017-09-29 Thread Ayan George
farid.m.zaka...@gmail.com wrote: > Is there a reason why GODOC only indexes packages it finds in $GOROOT ? I > would like to create indices of my personal packages + the standard library. > I think it does. It looks in my ${GOPATH} and gives me what docs it can for my poorly commented code.

Re: [go-nuts] go test fails - appear that it misses capturing stdout

2017-09-28 Thread Ayan George
On 09/28/2017 07:29 PM, gocss wrote: > first the code follow by output from 'go test -v' > Also, you can sort of fix this by copying os.Stdout within the example instead of the global var () section like: // this does not fail because iowr is a copy of os.Stdout after // it has been

Re: [go-nuts] go test fails - appear that it misses capturing stdout

2017-09-28 Thread Ayan George
On 09/28/2017 07:29 PM, gocss wrote: > first the code follow by output from 'go test -v' > Take a look at src/testing/example.go around line 15. The testing code temporarily re-assigns os.Stdout for the duration of the Example. It sets it to one of the end of a pipe that it uses to capture

Re: [go-nuts] Re: go 1.9 go test build fail on // Output:

2017-09-28 Thread Ayan George
gocss wrote: > good catch however the thing that made it not obvious > is that is it built without the // Output: line ... > Running go test -work can show why it fails ... further this does make > sense too > that no such testing args should be in

Re: [go-nuts] go 1.9 go test build fail on // Output:

2017-09-28 Thread Ayan George
On 09/28/2017 08:12 AM, gocss wrote: > go test > # testmain > /tmp/go-build584983468/csspc/alog/_test/_testmain.go:30:22: cannot use > alog.ExampleNew (type func(*testing.T)) as type func() in field value > FAIL    csspc/alog [build failed] > > code follows: > package alog > > import ( >    

Re: [go-nuts] go env GOPATH not reflecting $GOPATH

2017-08-31 Thread Ayan George
On 08/31/2017 09:38 PM, burpswangy wrote: > Debian 9.1 Stretch... using Go 1.9, go env shows GOPATH=/home/dev/go > while echo $GOPATH=/home/dev/devSync/workspace. > > No matter what I do, I can't get Go 1.9 to find my workspace! What is > goin' on!? > have you tried: export

Re: [go-nuts] Assigning files (names) to string array.

2017-08-31 Thread Ayan George
On 08/31/2017 08:41 PM, djl...@gmail.com wrote: > I am pretty new it GoLang but I am trying to read file directorys and > assign the directory name to array list. > > Exampe I have been working with this > > funccaptureDir() { >files, err:=ioutil.ReadDir("./") >iferr !=nil{ >

Re: [go-nuts] Understanding least significant byte operation

2017-07-23 Thread Ayan George
On 07/23/2017 08:50 AM, Pablo Rozas Larraondo wrote: > I have seen Go code using this function to find out the least > significant byte of unsigned integers: > > func LSB(ci uint64) uint64 { return uint64(ci) & -uint64(ci) } > > This function works fine but I wonder why, if call the same AND

Re: [go-nuts] Implicit cast of string vs. []byte

2017-06-24 Thread Ayan George
On 06/24/2017 08:16 PM, Ivan Bertona wrote: > Hello, > > When I try to compile this piece of code: > I think it violates the second assignability rule since both 'string' and MyString are named types. string happens to be a a pre-declared named type: https://golang.org/ref/spec#Assignability

Re: [go-nuts] Why *cookie and cookie variables returns the cookie in different format upon printing it to terminal?

2017-06-14 Thread Ayan George
; Hi Ayan, > > Thank you for pointing me to the right code. I saw there how string method > is creating the response. I think this is what I needed to see for my > question. Thank you. > > On Wednesday, 14 June 2017 22:28:55 UTC+5:30, Ayan George wrote: >> >> Hi Aman -- >>

Re: [go-nuts] Why *cookie and cookie variables returns the cookie in different format upon printing it to terminal?

2017-06-14 Thread Ayan George
Hi Aman -- When you print *http.Cookie, Go does it's best to print each field knowing that it is a pointer to a struct. This is the format you end up with. But http.Cookie has a String() method associated with it that provides the output that you get when you simply print 'cookie' (without the

Re: [go-nuts] Re: Generic service via interfaces...

2017-05-29 Thread Ayan George
On 05/29/2017 04:44 PM, Darko Luketic wrote: > > Ayan, no that's alright it was storage.UserModelInterface and I know > what you're all saying but I saw no other way to make them type > agnostic and I'm a fan of explicitly calling things what they are > especially when I'm experimenting. And

Re: [go-nuts] Help with Dataframes

2017-05-29 Thread Ayan George
On 05/29/2017 07:23 AM, Vikram Rawat wrote:> Can anybody please tell me how to write GOTA Golang dataframes on a csv... > > It's been 2 days I am trying to find a way to write dataframes onto a > csv. can anybody please help me understand what does this IO.writer > means and how to use it... > >

Re: [go-nuts] Generic service via interfaces...

2017-05-29 Thread Ayan George
On 05/28/2017 02:40 PM, Darko Luketic wrote: > I'm stuck and I hoped it wouldn't come to that. > As Justin said, interfaces on their own don't do anything and their zero value is nil. Beyond that I'd consider thinking more carefully about your interface names. Whenever I see the word

Re: [go-nuts] why iota can't be assigned to variables?

2017-05-03 Thread Ayan George
On 05/03/2017 10:38 AM, T L wrote: > > > On Wednesday, May 3, 2017 at 9:28:28 PM UTC+8, Jan Mercl wrote: > > On Wed, May 3, 2017 at 3:19 PM T L > wrote: > > Why would you want to assign iota to a variable? What value should > iota in such case have? > > > The request

Re: [go-nuts] sql: please, guys, tell me I am doing it wrong.

2017-04-03 Thread Ayan George
On 04/03/2017 08:50 AM, oju...@gmail.com wrote: > I built a little command line utility for running arbitrary sql queries. > You use it like: > > runQuery "select * from myTable" > > > Previously I have build similar tools in C and Java and I don't remember > needing to code a hack to

Re: [go-nuts] Best practice for Method Receivers

2017-03-27 Thread Ayan George
On 03/24/2017 09:20 PM, st ov wrote: > Is it idiomatic to mix-&-match pointer and value method receivers for > a given type? or in *_general_*, if a single method requires a > pointer receiver than *all methods* should take a pointer, regardless > if a value receiver is appropriate? > > For

Re: [go-nuts] Cross compiling from Windows to Linux produces non-working go routines

2017-03-08 Thread Ayan George
On 03/08/2017 08:30 AM, asci...@gmail.com wrote: > In the main function I call various go routines, I've set println after > each call, so I know they are being executed. But I don't get the > printlns I've set inside of some of those routines, for the same purpose. > So you are seeing some

Re: [go-nuts] Re: constant 256 overflows byte

2017-03-07 Thread Ayan George
On 03/07/2017 07:06 PM, Eric Brown wrote: > By the way, this is code snipped from within a conditional check, so > memoryBlock[2] will always be < 187 in this situation. > > On Tuesday, March 7, 2017 at 6:02:59 PM UTC-6, Eric Brown wrote: > > memoryBlock := make([]byte, 4) >

Re: [go-nuts] Re: constant 256 overflows byte

2017-03-07 Thread Ayan George
On 03/07/2017 07:06 PM, Eric Brown wrote: > memoryBlock[2] = 256 - (187 - memoryBlock[2]) ' results in error: > constant 256 overflows byte So since you're assigning to a byte I think Go is treating all of the constants as bytes. A byte can only encode between 0 and 255. You need an extra

Re: [go-nuts] Why is Go Unicode concat so slow compared to Python3 ?

2017-02-27 Thread Ayan George
On 02/27/2017 10:25 PM, Dan Kortschak wrote: > When the python functions are actually called the comparison is more > reasonable: > > ``` > ~/concat $ go test -bench . concat_test.go > BenchmarkUnicodeConcat-820 10379 ns/op > PASS > okcommand-line-arguments 2.193s

Re: [go-nuts] Why is Go Unicode concat so slow compared to Python3 ?

2017-02-27 Thread Ayan George
On 02/27/2017 07:21 PM, Ian Lance Taylor wrote: > On Mon, Feb 27, 2017 at 3:58 PM, Shubha Ramani > wrote: >> Please see the attached two scripts. >> >> Use python3 for concat_test.py. >> >> I'm getting 591 nsec for the micro benchmark in python and 4453 ns >> for the

Re: [go-nuts] How do I convert a byte into BigEndian or LittleEndian?

2017-02-27 Thread Ayan George
On 02/27/2017 04:45 PM, Glen Newton wrote: > > > |Given a byte b, how do I convert it to a byte of particular > endianness? It is not clear to me looking at ||"encoding/binary" > > (I am assuming that golang byte endianness varies across > ||architectures. If this is wrong please educate me).

Re: [go-nuts] Goroutine in a for loop: Closure versus direct

2017-02-25 Thread Ayan George
On 02/25/2017 03:48 AM, Amit Saha wrote: > > I think both these approaches are fine, but just wanted to check. > tl;dr: I think the second example is the way to go. I'm somewhat new to Golang so please someone correct me if I'm wrong. Neither of your examples are closures and, AFAIK,

[go-nuts] Building Go from Source / Managing my ${GOROOT}

2017-02-18 Thread Ayan George
I'm somewhat new to go and I've been relying on FreeBSD and Ubuntu packages for the compiler. I decided to try building Go from source to get go1.8 and I realized it is really convenient to simply clone the repo into my ${GOROOT}/src (which is now simply ${HOME}/go), build Go (I did extract 1.8

Re: [go-nuts] Unexpected Behaviour of goroutine

2017-02-12 Thread Ayan George
Srivathsan Madhavan wrote: > Hi all, > > I still consider myself a newbie to Golang hence my question here could be > due to my fundamental misunderstanding of this language > > I have the following code: > > func main() { > > for i := 0; i < 5; i++ { > > go

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread Ayan George
On 01/19/2017 02:00 AM, hui zhang wrote: > so the file seek does not work in bufio.Read ? > It looks like this has been answered before: https://groups.google.com/forum/#!topic/golang-nuts/mOvX0bmJoeI You could also create another bufio.Reader after you seek like: rd :=

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread Ayan George
On 01/19/2017 01:22 AM, hui zhang wrote: > I am using encoding/binary to read/write (struct)data to/from file. > Some times , I need to seek in the file while reading . > how to do this in go. > Check the code below [snip!] > > > fi, err := os.Open("./output.bin") >if err != nil { >

Re: [go-nuts] Hashing (u)int8

2016-12-16 Thread Ayan George
On 12/16/2016 07:01 PM, Ondrej wrote: > Hey, > I had int as a key in my map and later realised I only used 100 or so > values, so swapped it for a uint8, expecting a minor speed increase, but > saw a major slowdown instead. To recreate this, I tried this simple > microbenchmark and was surprised

Re: [go-nuts] float32 vs float64 precision lost when casting to int

2016-12-14 Thread Ayan George
On 12/14/2016 12:44 PM, Jan Mercl wrote: > On Wed, Dec 14, 2016 at 6:36 PM Mauro Romano Trajber > wrote: > >> The float to int conversion behaves different for 32 and 64 precision. >> https://play.golang.org/p/-zkCNSTbNa > I may be wrong but I

Re: [go-nuts] Re: Idiomatic way to remove duplicates in a slice

2016-12-14 Thread Ayan George
On 12/14/2016 12:14 PM, Michael Jones wrote: > Do we know anything about the structure of the slice? > > Just FYI -- this thread was started on 8/11/2012 and you, Michael, even responded to it at the time.. I think it was pretty well hashed out back then and I'm not sure why this was

Re: [go-nuts] Running commands via SSH

2016-11-26 Thread Ayan George
kburke...@gmail.com wrote: > Hi, I'd like to SSH to a remote host and run an arbitrary command. I found > this pretty difficult to do with existing Go libraries. > > The first problem I had was around escaping; commands run locally are > appropriately escaped but I found it difficult to get the