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

2022-11-23 Thread Ayan George
ributing things to Go. Saying "no" encourages people to abandon their pre-conceived notions and take Go for what it is. I recognize this is a kind of soft issue that is prone to bikeshedding. I considered it settled when Ian answered. -ayan -- You received this message because you are s

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 defini

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

2022-11-22 Thread Ayan George
ggest we'd classify it as a structured programming language with methods. In either case, is there a way to make the FAQ more clear on this point? -ayan -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

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

2022-10-26 Thread Ayan George
languages provide something similar or is this completely unique to Go? Can someone point me to or describe the history of Go's time formatting method? -ayan -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

[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 st

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

2018-01-18 Thread Ayan George
her making the Validate functions take a copy of the value: https://play.golang.org/p/qtpZDC6tezg or by making the members of MyStruct pointers: https://play.golang.org/p/cYghM8IipQ3 Check out the Method Sets section of the Go spec: https://golang.org/ref/spec#Method_sets -ayan -- You rec

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

2018-01-16 Thread Ayan George
or someone relatively new to programming: amzn.com/1491941952 It is fairly short and gives a really gentle introduction to Go without (IIRC) complaining about other languages. I'd probably recommend the following in order: * Introducing Go * The Go Programming Language * Concurrency in

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

2018-01-14 Thread Ayan George
uot;, http.StripPrefix("/", http.FileServer(http.Dir(*webrootdomain2 > If you're going to use the default http.Server and http.ServeMux, I think that's the way to go. Please disregard my wrong response. -ayan -- You received this message because you are subscribed t

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

2018-01-10 Thread Ayan George
http.Dir(*webrootdomain2 > Wow! Reading is fundamental. I didn't know ServeMux handled the domain name. I wish I could take back my previous email now. :) -ayan -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe fr

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

2018-01-09 Thread Ayan George
does re-declare existing variables (of the same type!). That behaves like assignment but I think it is still declaration. But its behavior makes sense if you consider that you can't declare or re-declare struct member. -ayan -- You received this message because you are subscribed to the Googl

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 serve different directo

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 m

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' chann

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 subscrib

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 t

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 wou

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. To

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

2017-10-27 Thread Ayan George
y high. I think whether it is 'performant' depends on your requirements. I'd start by using the test tool to benchmark your code that needs reflect too see if it meets your needs. -ayan -- You received this message because you are subscribed to the Google Groups "golang-nut

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

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

2017-10-22 Thread Ayan George
why you only read one byte: Because you only make your receiving buffer (buf) in the server 1 byte. Instead of: buf := make([]byte, 1) try: buf := make([]byte, 0, 20) or read into your buf using a loop. -ayan -- You received this message because you are subscribed to the Google Groups "

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

2017-09-29 Thread Ayan George
nted code. -ayan -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

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 'hijacked'

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

2017-09-28 Thread Ayan George
uses to capture the output of anything that writes to os.Stdout. Since you are logging to a copy of os.Stdout, your first test wirtes to a copy of os.Stdout and thus escapes/avoids having it's output captured by go test. I think the short answer is: don't do that? -ayan -- You receive

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

2017-09-28 Thread Ayan George
tly by either reading the docs or asking for help and I doubt you'll ever make this mistake again. Maybe you should also add go vet to your toolbox if it isn't already there? -ayan -- You received this message because you are subscribed to the Google Groups "golang-nuts" gr

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

2017-09-28 Thread Ayan George
lags(0) >     // Output: 123 > } > ExampleNew() shouldn't take a *testing.T. Its signature should be just: func ExampleNew() { ... } I get it. It is probably habit to add testing.T to tests. :) -ayan -- You received this message because you are subscribed to the Google Group

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 GOPATH=/home/dev/

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

2017-08-31 Thread Ayan George
quot;./") >iferr !=nil{ >log.Fatal(err) >} > > for_, f:=rangefiles { >dirlist[f] = f.Name >} > } > Name is a method not a variable so it should be f.Name(). There might be other issues with that snippet though. -ayan -- You received th

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

2017-07-23 Thread Ayan George
t expressions are illegal..." BUT, the rules for expressions that cause overflow are well defined and operations on the variable 'ci' abide by them. So I think it is a matter of compile-time correctness vs runtime behavior. The following also works: https://play.golang.org/p/G

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

2017-06-24 Thread Ayan George
orrect me if I'm wrong. -ayan -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

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
Well -- I was wrong. I got it backwards. There is a String() function is a receiver for *http.Cookie so it gets called when you need a string representation of a *http.Cookie (pointer to http.Cookie). On Wed, Jun 14, 2017 at 1:18 PM, Aman Kapoor wrote: > Hi Ayan, > > Thank you for po

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 a

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 > especial

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
;t quite roll off the tongue as easily. :) It seems like using a simple and descriptive noun reflects a clearer mental model for what you are trying to abstract. When I see "interface" used in an interface name it tells me that you're not trying to abstract behavior; you're u

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 is not essential, b

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

2017-04-03 Thread Ayan George
remember > needing to code a hack to handle a variable number of columns. > > https://play.golang.org/p/6WOu1SzgcZ > Just going from the documentation, rows.Scan() is a variadic function so you should be able to do something like: cols, _ := rows.Columns() v := make([]interf

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

2017-03-27 Thread Ayan George
all of them must be (or vice versa). -ayan -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

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

2017-03-08 Thread Ayan George
t; So you are seeing some Println()s but not others or are you not seeing any Println()s at all? -ayan -- 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, s

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) > binary.Litt

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 bit

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
noticed the same thing. Even after you do call myinit() the performance difference is still the same with python2.7. python3 has similar performance to Go: ayan@kiwi:~/unicode$ python --version Python 2.7.13 ayan@kiwi:~/unicode$ python ./concat_test.py time_taken = 924.661159515 nsec ay

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
wrapping it in an anonymous function doesn't buy you anything. If it were two or three statements I think it'd be worthwhile. -ayan -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

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

2017-02-18 Thread Ayan George
xtract 1.8 binaries to bootstrap my environment), and add ${HOME}/go/bin to my path. Now I don't have to worry about finding the latest source and I can even keep up with new developments by pulling new code. Am I missing anything by not using the packages? Is this idiomatic? -ayan -- Yo

Re: [go-nuts] Unexpected Behaviour of goroutine

2017-02-12 Thread Ayan George
ke: log.Printf("i = %d, &i = %p", i, &i) The addresses should be the same. If you want each goroutine to have a copy of I, you should declare and run gofunc() like below: gofunc(c int) { log.Println("c=",c) }(i) Which passes a copy of i to eac

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

2017-01-18 Thread Ayan George
e a notion of where it is in the file -- it just contains a buffer, read and write positions within that buffer, etc. -ayan -- 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

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

2017-01-18 Thread Ayan George
err = binary.Read(rd, binary.LittleEndian, &pi) >if err != nil { > fmt.Println("binary.Read failed:", err) >} >fmt.Println(pi) > >fi.seek()? > Is File.Seek() what you're looking for or do you need something else? https://golang.org/pkg/os/#Fi

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

2016-12-16 Thread Ayan George
iness was outweighed by this hashing performance difference. > It looks like any type that isn't the size of a word is slower. Probably due to all sort of masking and maybe shifting it has to do. -ayan -- You received this message because you are subscribed to the Google Groups "golan

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

2016-12-14 Thread ayan
On Wednesday, December 14, 2016 at 12:56:58 PM UTC-5, Ayan George wrote: > > > In fact, 80917.64 does predictably work with both types. > And I get the same results in C. -- You received this message because you are subscribed to the Google Groups "golang-nuts" grou

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 think that 32 bit floatin

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

2016-12-14 Thread Ayan George
e why this was resurrected: https://groups.google.com/forum/#!topic/golang-nuts/-pqkICuokio -ayan -- 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

Re: [go-nuts] Running commands via SSH

2016-11-26 Thread Ayan George
;d be interesting to know if there is a way to get ssh to execute a command without invoking the login shell. After a quick glance of the man page and source (for FreeBSD at least) I couldn't find a way. -ayan -- You received this message because you are subscribed to the Google Groups &q