Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-26 Thread Andy Balholm
There is no guarantee that the unsafe package even exists in every implementation of Go. For example, I really doubt that GopherJS has it. But that keep GopherJS from being compliant with the Go spec and the Go 1 compatibility guarantee. (I’m not sure whether GopherJS is to the point of full co

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-26 Thread Andy Balholm
Oops. I left out a couple words. I meant “does not keep”. Andy > On Feb 26, 2018, at 9:23 AM, Andy Balholm wrote: > > There is no guarantee that the unsafe package even exists in every > implementation of Go. For example, I really doubt that GopherJS has it. But > that kee

Re: [go-nuts] [ANN] oksvg and rasterx; SVG 2.0 path compliant renderer and rasterizer

2018-04-25 Thread Andy Balholm
So it sounds like the AGPL is a good license to choose if you want to keep your code from being used by big companies… ;-) > On Apr 25, 2018, at 8:48 AM, 'David Chase' via golang-nuts > wrote: > > > > On Tuesday, April 24, 2018 at 10:45:35 AM UTC-4, matthe...@gmail.com wrote: > I’m curious i

Re: [go-nuts] why does go reverse the order of name and type? "i int" vs "int i"

2018-09-20 Thread Andy Balholm
It made sense to Ken and Dennis back when C’s type system was a lot simpler than it is now, anyway. > On Sep 20, 2018, at 7:40 AM, Michael Jones wrote: > > the other answer is: "for c it made sense to ken and dennis, alas, we are not > them" > > On Thu, Sep 20, 2018 at 1:32 AM Eric S. Raymon

[go-nuts] Operators in interfaces

2018-10-17 Thread Andy Balholm
Warning: yet another generics-related idea ahead. :-) The motivation for using contracts instead of interfaces as the type constraints in the Go 2 generics proposal is the fact that interfaces only allow one type of operation: method calls. And we’d like to be able to use other operations, such

Re: [go-nuts] Regarding contracts

2018-10-17 Thread Andy Balholm
That’s a very interesting idea. It would probably need to be extended to allow specifying that a type is like multiple types. Then the effective “contract” would be the intersection of the operations provided by those types. For example, we would want to be able to specify a type that is like bo

Re: [go-nuts] Regarding contracts

2018-10-17 Thread Andy Balholm
I think there are serious issues with your syntax for functions and “templates.” For example, there doesn’t seem to be a way to specify that two parameters to a function need to be the same type, or that the return type will be the same as the parameter. The syntax from the official proposal is

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Andy Balholm
I don’t think that generic functions should have access to private fields of their type parameters, regardless of what package they are in. Andy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Andy Balholm
That would also be a weakness of most of the other proposals, including my own to add operators to interfaces. Contracts are more powerful, at the expense of extra complexity. Andy > On Oct 18, 2018, at 10:34 AM, Ian Lance Taylor wrote: > > On Wed, Oct 17, 2018 at 11:58 AM, Burak Serdar wrot

Re: [go-nuts] Avoiding overloading

2018-10-19 Thread Andy Balholm
It seems to me that what you are proposing with “implements” is not really a replacement for contracts. It would do something that contracts don’t (unify operators and methods), and it wouldn’t do nearly all of what contracts do (clearly define what is expected of type parameters across a wide r

Re: [go-nuts] Avoiding overloading

2018-10-20 Thread Andy Balholm
, powerful idea; it's working out the implications that ties people’s brains in knots. Andy > On Oct 19, 2018, at 9:18 PM, Eric S. Raymond wrote: > > Andy Balholm : >> It seems to me that what you are proposing with “implements” is not really a >> replacement for contra

Re: [go-nuts] Regarding contracts

2018-10-24 Thread Andy Balholm
Here’s my attempt at streamlining it, as well as adding a way to deal with the operator/method dichotomy: https://gist.github.com/andybalholm/8165da83c10a48e56590c96542e93ff2 Andy > On Oct 23, 2018, at 9:37 AM, Burak Serdar

Re: [go-nuts] Regarding contracts

2018-10-24 Thread Andy Balholm
{ if a < b { return a } return b } Andy > On Oct 24, 2018, at 9:47 AM, Burak Serdar wrote: > > On Wed, Oct 24, 2018 at 10:22 AM Andy Balholm wrote: >> >> Here’s my attempt at streamlining it, as well as adding a way to deal with

Re: [go-nuts] Regarding contracts

2018-10-25 Thread Andy Balholm
> On Oct 25, 2018, at 6:45 AM, Marvin Renich wrote: > > The most powerful feature of the contracts described in the original > design draft is the ability to describe interactions between two types > in a type specification. Your proposal doesn't seem to allow this. See the section of my gist

Re: [go-nuts] Regarding contracts

2018-10-26 Thread Andy Balholm
018, at 9:41 AM, Burak Serdar wrote: > > On Thu, Oct 25, 2018 at 10:32 AM Andy Balholm <mailto:andybalh...@gmail.com>> wrote: >> >> >> >> On Oct 25, 2018, at 6:45 AM, Marvin Renich > <mailto:m...@renich.org>> wrote: >> >> Th

Re: [go-nuts] Generics: an unwelcome conclusion and a proposal

2018-11-03 Thread Andy Balholm
I thought of a way to do something similar to the “implements” proposal without introducing operator overloading: turn it around. Instead of letting methods implement operators, we could let operators implement methods. type Lesser(type T) interface { Less(b T) bool for(<) } This interf

Re: [go-nuts] Generics: an unwelcome conclusion and a proposal

2018-11-05 Thread Andy Balholm
The concept of using operators to implement methods cross-pollinated in my mind with Patrick’s “Go Generics with Adaptors” thought experiment and produced this: https://gist.github.com/andybalholm/acecba3acf57bf1254142dadce928890

Re: [go-nuts] Generics: an unwelcome conclusion and a proposal

2018-11-06 Thread Andy Balholm
t 7:59 PM, Lucio wrote: > > The word "elegant" comes to mind... Comments below. > > On Monday, 5 November 2018 21:47:46 UTC+2, Andy Balholm wrote: > The concept of using operators to implement methods cross-pollinated in my > mind with Patrick’s “Go Generics with A

Re: [go-nuts] Generics: an unwelcome conclusion and a proposal

2018-11-08 Thread Andy Balholm
I’ve updated my gist at https://gist.github.com/andybalholm/acecba3acf57bf1254142dadce928890 <https://gist.github.com/andybalholm/acecba3acf57bf1254142dadce928890> to use contracts as adaptors. Andy > On Nov 6, 2018, at 8:27 PM, Andy Balholm wrote: > > It is implicit: the fu

Re: [go-nuts] Is conversion between int and uint a no-op i.e. is it free

2018-11-24 Thread Andy Balholm
There is nothing in the language spec that guarantees anything about performance. But if logic tells you that it should be a no-op, and examination of the generated code shows you that it is a no-op in the cases you tested, you can safely assume that it is not going to be an issue for your progr

Re: [go-nuts] Strange behaviour of left shift

2018-12-05 Thread Andy Balholm
Apparently in your code the value is being assigned to an int. But it’s too large for an int; it needs a uint64 to hold it. Andy > On Dec 5, 2018, at 8:35 AM, Michel Levieux wrote: > > Hi guys, > > With a colleague of mine, we've run into a strange issue today. When we look > at package math

Re: [go-nuts] Strange behaviour of left shift

2018-12-05 Thread Andy Balholm
:54 AM, Michel Levieux wrote: > > Well the only thing I do in the main is : > > fmt.Println(v) > > Shouldn't the compiler statically type v to uint64? > I don't get the need to force type of v to uint64? > > Le mer. 5 déc. 2018 à 17:45, Andy Balholm

Re: [go-nuts] Strange behaviour of left shift

2018-12-06 Thread Andy Balholm
That would definitely be possible. But it isn’t likely to happen. It would make the rule several times more complicated that it currently is, to fix something that only happens occasionally, is caught at compile time, and is easily taken care of with an explicit type conversion. That doesn’t sou

Re: [go-nuts] What are the reasonable reasons to use pointers?

2019-01-01 Thread Andy Balholm
Some languages, like Java, don’t have explicit pointer types. But they do it by making almost everything an implicit pointer. Andy > On Jan 1, 2019, at 9:13 AM, Jan Mercl <0xj...@gmail.com> wrote: > > > On Tue, Jan 1, 2019 at 12:34 PM 伊藤和也 > wrote: > > > Wha

Re: [go-nuts] What are the reasonable reasons to use pointers?

2019-01-02 Thread Andy Balholm
And yet Knuth wrote TeX with virtually no pointers, because he didn’t trust the dynamic memory allocators in many Pascal implementations (probably from bitter experience). So he used array indices as s substitute for pointers. Andy > On Jan 2, 2019, at 3:13 AM, Chris FractalBach wrote: > > "I

Re: [go-nuts] C++ 11 to Golang convertor

2019-01-03 Thread Andy Balholm
I’ve been working on a tool (called leaven) to convert LLVM IR (intermediate representation) to Go. So you can compile C to LLVM with clang, and then convert the result to Go. It’s actually pretty easy, because LLVM instructions are such simple operations. But it’s not very readable; given this:

Re: [go-nuts] C++ 11 to Golang convertor

2019-01-03 Thread Andy Balholm
code used > CGo for all of its work. > > It gets really difficult for multithreaded apps, pthread does not translate > to Go routines, no TLS, etc. > > I think correcting the converted Go would be more daunting that just > rewriting it in Go to begin with. > &g

Re: [go-nuts] C++ 11 to Golang convertor

2019-01-03 Thread Andy Balholm
It’s at https://github.com/rsc/c2go . It might be a good starting place, but there is one significant difference in approach from what Eric is proposing. Russ incorporated all of the manual cleanup into the tool (or config files) as special cases, rather than leaving

Re: [go-nuts] C++ 11 to Golang convertor

2019-01-05 Thread Andy Balholm
Yes, the preprocessor… The preprocessor is one of the biggest obstacles to readable C-to-Go translation. rsc/c2go largely ignores preprocessor directives other than #include—and it doesn’t include a translation of the headers at the top of every output file. But most C programs are a lot more d

Re: [go-nuts] Using "er" and "able" for interfaces

2019-01-18 Thread Andy Balholm
The -er suffix makes sense when you think of a method invocation as a command, telling an object to do something. This was definitely the model in Smalltalk, where people called them “messages.” In Go, methods are more like functions than in Smalltalk, but some of the idea remains in the naming

[go-nuts] brotli: my c2go experience

2019-03-16 Thread Andy Balholm
Over the last few months, I’ve been working (on and off) at translating the Brotli compression library into Go. (The result is at github.com/andybalholm/brotli.) I’d like to share what I’ve learned. I tried various tools: rsc/c2go, elliotchance/c2go, Konstantin8105/c4go, and a tool that I devel

[go-nuts] Re: brotli: my c2go experience

2019-03-23 Thread Andy Balholm
% 45.647576ms 11.8 MB/s gzip-9 30.6% 47.600027ms 11.4 MB/s > On Mar 16, 2019, at 3:55 PM, Andy Balholm wrote: > > Over the last few months, I’ve been working (on and off) at translating the > Brotli compression library into Go. (The result is at > github.com/andybalholm/br

Re: [go-nuts] pet peeve: it's Go not golang

2017-07-25 Thread Andy Balholm
Even “go game of life” works. Some search engines may treat “of” as a stopword, but Google gives it some weight. Andy > On Jul 25, 2017, at 4:18 PM, Skip Tavakkolian > wrote: > > I was specifically referring to things posted to this list to avoid the old > chestnut about search. > > For wha

Re: [go-nuts] No Allman-Style, No go!

2017-07-29 Thread Andy Balholm
It’s not quite true that the compiler doesn’t care about white space. The lexer is part of the compiler, and it does care about white space. The semicolon insertion rule, in particular, pays attention to newlines. So, while the compiler doesn’t care about indentation at all, there are some brac

Re: [go-nuts] No Allman-Style, No go!

2017-07-29 Thread Andy Balholm
I’ve always considered the lexer to be part of the compiler, and apparently Ecstatic Coder does too, considering his complaint. Andy > On Jul 29, 2017, at 2:58 PM, Jan Mercl <0xj...@gmail.com> wrote: > > On Sat, Jul 29, 2017 at 10:43 PM Andy Balholm <mailto:andybalh...

Re: [go-nuts] Storing uint64 values in DB

2017-07-29 Thread Andy Balholm
var i uint64 var j int64 … j = int64(i) This performs the same conversion that C would do automatically when assigning i to j, but Go requires you to be a little more explicit. > On Jul 29, 2017, at 6:54 PM, Tong Sun wrote: > > Neither PostgreSQL[1] nor SQLite[2] support unsigned 64-bit intege

Re: [go-nuts] Do you guys use ORMs when working with SQL?

2017-09-11 Thread Andy Balholm
> Why would someone want to switch from PostgreSQL to MySQL? I recently switched a project from PostgreSQL to MySQL. But I sure can’t say I *wanted* to. We were integrating a dependency that only supports MS SQL Server and MySQL. -- You received this message because you are subscribed to the G

Re: [go-nuts] "html/dom" alternative to html/template for true separation of concerns?

2017-09-13 Thread Andy Balholm
It sounds like what you’re wanting to do is basically what is called Template Animation at http://www.workingsoftware.com.au/page/Your_templating_engine_sucks_and_everything_you_have_ever_written_is_spaghetti_code_yes_you

Re: [go-nuts] "html/dom" alternative to html/template for true separation of concerns?

2017-09-13 Thread Andy Balholm
You may not be aware that the html/template package does automatic escaping. So if a template has {{.Blogpost}} and Blogpost contains alert(“Pwned”), the result will be something like Assigning to the div’s innerHTML would be bad in this case, but appending a te

Re: [go-nuts] "html/dom" alternative to html/template for true separation of concerns?

2017-09-13 Thread Andy Balholm
a database all hell should break loose) - but > as files could under certain circumstances also be user-created (i.E. some > esoteric database where every blog entry is a file) there's a problem here. > One can't prevent coders from making mistakes. PHP tried, it failed. ^^ Java

Re: [go-nuts] "html/dom" alternative to html/template for true separation of concerns?

2017-09-14 Thread Andy Balholm
ote: > > It = html/template > "The purpose" = the one I thought I could use it for and described above. > > Am Donnerstag, 14. September 2017 03:58:02 UTC+2 schrieb Andy Balholm: > Why does automatic escaping make html/template completely impractical? (Or > did I guess

Re: [go-nuts] "html/dom" alternative to html/template for true separation of concerns?

2017-09-14 Thread Andy Balholm
do forget about > proper sanitization of user-input. As I'm pretty focused on security, I know > about the implications of many design-approaches. Easy-to-use approaches are > neat and in that certain case super useful - but sadly not for my use-case. ^^ > > @Andy Balholm: No,

Re: [go-nuts] Golang, Google App Engine, Windows 10

2017-09-22 Thread Andy Balholm
One reason might be if you’re using a server version of Windows. For some reason, the Linux subsystem is only for consumer versions. Andy > On Sep 21, 2017, at 5:50 AM, Rob Shelby wrote: > > Why would I use Cygwin over Bash For Windows? > > On Thursday, September 21, 2017 at 8:17:04 AM UTC-4

Re: [go-nuts] Handling dynamic and unknown number of wait groups?

2017-11-02 Thread Andy Balholm
You can add goroutines to a WaitGroup as you create them. There is nothing that keeps you from calling Add more than once. Andy > On Nov 1, 2017, at 11:10 PM, kanth...@gmail.com wrote: > > I am new to Go and I had read numerous times in various articles that one can > technically create any nu

Re: [go-nuts] cgo style question

2017-11-03 Thread Andy Balholm
Use the arr1 style when the length of the C array is known at compile time, and the arr2 style when it’s not known till runtime. Andy > On Nov 3, 2017, at 9:18 AM, DV wrote: > > Which "style" of wrapping a C array in a Go slice is more idiomatic in this > code - https://play.golang.org/p/6EbK

Re: [go-nuts] Go Compiler How Work?!

2017-12-13 Thread Andy Balholm
No, the Go compiler doesn’t actually generate ASM. It generates machine code. So it doesn’t need the help of another compiler or assembler. Andy > On Dec 13, 2017, at 9:00 AM, Compiler wrote: > > i am undrestand compiler steps. > only have problem in code generation step. > so best way is this

Re: [go-nuts] Go Compiler How Work?!

2017-12-13 Thread Andy Balholm
that the target operating system expects.) Andy > On Dec 13, 2017, at 9:31 AM, Compiler wrote: > > Machine Code?! > > please show me github link source file then at they is generate sample > binary... at GOLANG sources. > > On Wednesday, December 13, 2017 at 8

Re: [go-nuts] database/sql : i have a need to use postgresql numeric column data type for currency / money value processing

2018-01-08 Thread Andy Balholm
If all the calculations are going to be in the database, you can just use strings on the Go side. Andy > On Jan 7, 2018, at 6:44 AM, evan wrote: > > c# has a decimal type that i can map my numeric(12,2) column data type to, > but golang doesnt have a decimal type. > > i'm trying to avoid sto

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

2018-01-09 Thread Andy Balholm
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 -- You received this message because you are subscribed to the Google Groups "golang

Re: [go-nuts] Difficulties Using golang.org/x/net/html

2018-01-26 Thread Andy Balholm
The prescription is correct; the diagnosis is close but not exactly right. The html package actually doesn’t pay any attention to the XML-style self-closing tag syntax. It accepts it, in accordance with the HTML5 spec, as an alternate style of opening tag, but it never closes an element just bec

Re: [go-nuts] Is it possible to simplify this snippet?

2019-05-01 Thread Andy Balholm
You could have a cleaner switch statement if you had a list of the keys that were pressed, instead of needing to check each one individually: func whichKeys(keysToCheck ...keyID) []keyID { var result []keyID for _, k := range keysToCheck { if rl.IsKeyDown(k) {

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Andy Balholm
When the program exits, the operating system releases all the memory allocated to it. So the GC doesn’t need to bother with freeing the memory. Andy > On May 3, 2019, at 5:49 PM, Matt Harden wrote: > > On Fri, May 3, 2019, 17:28 mailto:lgod...@gmail.com>> > wrote: > Does Go GC destroy all gl

Re: [go-nuts] the Dominance of English in Programming Languages

2019-05-17 Thread Andy Balholm
That’s probably true of the spoken language; American spelling, on the other hand, has changed more than British spelling. This is mostly a result of Noah Webster’s attempts to simplify it. King James Version Bibles generally follow the spelling of the 1769 Oxford printing, and the spelling is

Re: [go-nuts] the Dominance of English in Programming Languages

2019-05-18 Thread Andy Balholm
Just be glad that the American date format caters to (or for!) those Americans who say “January two”, not those who (like me) say “January second.” Imagine what date-formatting code would look like if ordinal suffixes were required! (Jan 1st, Jan 2nd, etc.) Andy > On May 18, 2019, at 2:59 AM,

[go-nuts] In module mode, where does "go install" install executables

2019-06-25 Thread Andy Balholm
When GOPATH is set, “go install” installs executables to $GOPATH/bin (assuming there is just one path in GOPATH). When GOPATH is not set, where do the executables go? I haven’t been able to find them. Andy -- You received this message because you are subscribed to the Google Groups "golang-n

Re: [go-nuts] In module mode, where does "go install" install executables

2019-06-25 Thread Andy Balholm
Yes, it looks like that is right. Andy > On Jun 25, 2019, at 9:25 AM, Wagner Riffel wrote: > > I'd bet the default GOPATH, that is $HOME/go > BR. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receivin

Re: [go-nuts] Announcing gg ("gigi") your new friend

2019-07-04 Thread Andy Balholm
I recently ran across https://github.com/mvdan/gogrep . It does some of that. Andy > On Jul 4, 2019, at 5:30 PM, Bakul Shah wrote: > > Very nice! > > A natural great extension[1] would be language aware grep/sed/awk: > - return an enclosing parse construct aft

Re: [go-nuts] possible to set tls.Config.Servername with http.client.Do

2019-07-15 Thread Andy Balholm
If you leave the Servername blank, http.Transport will get it from the HTTP request. Andy > On Jul 15, 2019, at 12:27 PM, efah...@gmail.com wrote: > > Hi, > > I was wondering how one can do concurrent tls requests with one single > http.Client where all the servers serving the request have t

Re: [go-nuts] ls: unsupported SSLv2 handshake received

2019-09-18 Thread Andy Balholm
As I understand it, the issue isn’t actually about SSLv2 itself. It’s that clients that support SSLv2 use an old handshake format. In that handshake, they can advertise support for SSLv3 and maybe even TLS 1. So if crypto/tls added support for the handshake but not the rest of SSLv2, they could

Re: [go-nuts] early close of http.Client's Response.Body

2019-11-25 Thread Andy Balholm
> On Nov 25, 2019, at 9:54 AM, Liam wrote: > > - does the read-to-EOF stipulation also apply to Client.Get/Post() ? Yes. Those methods are fairly simple wrappers around Do. > - why does Response.Body.Close() before io.EOF not release unread buffers or > otherwise prepare it for persistence?

Re: [go-nuts] early close of http.Client's Response.Body

2019-11-25 Thread Andy Balholm
are met. Otherwise Close will close the connection. There is no need to discard a Client after an early Close. A Client is not tied to a single connection. Andy > On Nov 25, 2019, at 11:10 AM, Liam Breck wrote: > > > > On Mon, Nov 25, 2019, 10:32 AM Andy Balholm &

Re: [go-nuts] Looking for an app w/ mult. versions of a dependency

2019-12-05 Thread Andy Balholm
I’m pretty sure there is no “otherwise simple” example, because depending on two versions of the same library isn’t usually something a project does deliberately (except as a last resort). It’s normally the consequence of an extremely complex forest of dependencies. Andy > On Dec 5, 2019, at 5

Re: [go-nuts] Win xp

2016-08-30 Thread Andy Balholm
https://golang.org/doc/install says that Windows XP is supported. Maybe your Windows 10 machine is 64-bit and your Windows XP machine is 32-bit. Try setting the GOARCH environment variable to 386 before you compile to generate 32-bit EXE files. Andy -- You rec

Re: [go-nuts] Go string to uintptr

2016-09-06 Thread Andy Balholm
If you use cgo, there is a helper function C.CString to do this. You can convert the string to a []byte, append 0 (for a null-terminated string), and take the address of the first byte. Andy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To u

Re: [go-nuts] Adding YAML to the stdlib

2016-09-23 Thread Andy Balholm
What do you mean by “community”? Is it those of us who aren’t employed by Google? Is it any more unfair for the Go team at Google to expect Gustavo (or others) to maintain his YAML package than for some in the community to expect the Go team to take it over? Andy -- You received this message

Re: [go-nuts] TimeZone Query: Time Difference between EST and UTC

2016-09-29 Thread Andy Balholm
Right now there is a 4-hour difference between Eastern (Daylight) Time and UTC. But you asked for “EST”, and that is what you got: Eastern *Standard* Time. If you want a Location that automatically switches between EST and EDT, ask for “America/New_York”. Andy -- You received this message bec

Re: [go-nuts] Reading http.Request.Body...

2016-10-11 Thread Andy Balholm
I think what you need is io.ReadFull. Andy -- 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 http

Re: [go-nuts] Deleting the /r/golang subreddit

2016-11-28 Thread Andy Balholm
I took the usage of “men” in that comment to be gender-neutral. I read it as “Are you rankist?", not as “Are you sexist or rankist?” (I don’t know if rankist is a word, but I mean someone who discriminates on the basis of rank.) Andy > On Nov 27, 2016, at 6:43 PM, vac...@gmail.com wrote: > >

Re: [go-nuts] validating self-signed certs

2016-12-08 Thread Andy Balholm
Why not make a tls.Config that trusts all the self-signed certs for all the different devices, and make one Transport with that config? Andy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving email

Re: [go-nuts] validating self-signed certs

2016-12-08 Thread Andy Balholm
So the set of devices keeps changing. I think you can make an http.Transport with a custom DialTLS function that always uses an up-to-date TLS config. Andy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and sto

Re: [go-nuts] How to speed up execution time for a set of regular expressions

2016-12-13 Thread Andy Balholm
If it’s actually just a list of keywords (no wildcards, character ranges, etc.), I would recommend using Aho-Corasick string matching rather than regular expressions. Andy > On Dec 13, 2016, at 7:53 AM, David Sofo wrote: > > Hi, > > For a set of rules expressed in regular expression (around

Re: [go-nuts] How to speed up execution time for a set of regular expressions

2016-12-13 Thread Andy Balholm
Right. Aho-Corasick can’t be used directly in that case. But it might still be a major performance win to use Aho-Corasick for the first pass, and then confirm with regexes. In other words, if the Aho-Corasick stage finds “associate,” then check whether /associate.*with/ matches. Andy -- You

Re: [go-nuts] howto: compile template against well-known structure ?

2016-12-19 Thread Andy Balholm
I don’t know if this will be helpful to you or not, but I’ve made a package that is basically a copy/paste of the autoescaping logic from html/template, but modified to work at runtime instead of when compiling a template: github.com/andybalholm/escaper I

Re: [go-nuts] Do you guys use ORMs when working with SQL?

2016-12-30 Thread Andy Balholm
On Dec 30, 2016, at 4:43 AM, paraiso.m...@gmail.com wrote: > > Ultimately even if you stick to SQL you are just also writing your own ORM , > you just can't generalize code because of Go type system. There are really two separate (but related) issues in the ORM debate: the ORM design pattern, a

Re: [go-nuts] Google Grumpy (Python->Go)

2017-01-04 Thread Andy Balholm
Finally, a way to deploy a Python program as a statically-linked binary! The Go code this produces looks awful. It’s more like threaded code in Go syntax than like real Go. It translated my toy benchmark function def count(x): i = 1 while i <= x: i += 1 into

Re: [go-nuts] should every .gz file be served with content-encoding gzip?

2017-01-14 Thread Andy Balholm
It all depends on what the user wants to have when they are done downloading. In the case of HTML, CSS, and JS, they want an uncompressed file that is ready for their browser to use. So you should use Content-Encoding: gzip and Content-Type: text/html or whatever. In the case of a .tar.gz, they

Re: [go-nuts] should every .gz file be served with content-encoding gzip?

2017-01-14 Thread Andy Balholm
est to a foo request? Why should a user want to have > a .gz file after downloading? > > On Sat, Jan 14, 2017 at 1:31 PM Andy Balholm <mailto:andybalh...@gmail.com>> wrote: > It all depends on what the user wants to have when they are done downloading. > In the case of HTML, CS

Re: [go-nuts] feature request: allow literal digit underscore grouping

2016-06-22 Thread Andy Balholm
Actually, the mention of gofmt brings up the issue of consistent formatting. If underscores in numbers were allowed, gofmt should automatically insert them for all numbers over a given length, and remove them for shorter numbers. Otherwise it would just be another opportunity for inconsistency,

Re: [go-nuts] feature request: allow literal digit underscore grouping

2016-06-22 Thread Andy Balholm
The same is true of brace styles :-P. But my point is that by not allowing digit grouping, Go avoids style debates on that issue. The grouping could have been standardized with gofmt, but as it is, it is standardized by the compiler to a format that is universally understood (no grouping). And

Re: [go-nuts] Error vs. Panic: Should functions like strings.Repeat return an error value?

2016-06-30 Thread Andy Balholm
When a function is used incorrectly, a panic is appropriate. If the count comes from an untrusted source, the caller should check that it is non-negative (and not too large) before calling Repeat, rather than checking an error afterward. Using a uint would actually be worse, since uint(int(-1))

Re: [go-nuts] Error vs. Panic: Should functions like strings.Repeat return an error value?

2016-07-06 Thread Andy Balholm
Yes, panic would probably have been a better choice there. In the API cleanups leading up to Go 1, the team removed some of the error returns from the NewWriter functions in the compress/* packages (https://codereview.appspot.com/5639057), but maybe it would have been good to go farther. Andy

Re: [go-nuts] Error vs. Panic: Should functions like strings.Repeat return an error value?

2016-07-06 Thread Andy Balholm
In this particular case, the only possible error is that the compression level is invalid. The documentation says that the error will be nil if the level is valid. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group a

Re: [go-nuts] Speeding up multiple regexp matches

2016-07-27 Thread Andy Balholm
in github.com/andybalholm/redwood , one thing I do is to check each URL against a (potentially very large) set of regular expressions. Since these regular expressions generally contain fairly significant amounts of literal text, I analyze each regular expre

Re: [go-nuts] Initialize Variables in case clause of a switch

2016-08-05 Thread Andy Balholm
I’ve wished for it too, but I just use an else/if chain in that case. Andy -- 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.c

Re: [go-nuts] Getting root file path of USB pen drive

2016-08-18 Thread Andy Balholm
On Mac, you can get a listing of /Volumes, and ignore whichever entry is a symlink to / (since that is the boot drive). This will give you both external drives and network shares; I’m not sure if there is an easy way to distinguish the two; one possibility is that physical drives seem to be owne

Re: [go-nuts] Migrating from a classic OO pattern

2017-01-30 Thread Andy Balholm
The second thing you tried is usually the best way to do this in Go: define an interface with the methods that vary by type, and then make a function with the type-independent logic. It’s actually cleaner in many cases than the classic OO way with overriding methods, but a direct translation fro

Re: [go-nuts] What is use for [:] of a slice?

2017-01-30 Thread Andy Balholm
Most likely they originally used an array, and changed it to a slice later. Since that line still compiled, it didn’t get changed. Or else they are just confused. Anyway, I can’t think of any reason to use [:] on a slice either. Andy -- You received this message because you are subscribed to

Re: [go-nuts] Help - main.go:15: undefined: say

2017-01-30 Thread Andy Balholm
You defined say inside main, but Super is defined outside main, so say is not in scope there. Move the definition of say outside of main, so that it is a top-level (global) declaration. Andy PS Even after you do that, your program will print 9000 rather than 19000, because Super is modifying a

Re: [go-nuts] Appending a path to an URL

2017-01-31 Thread Andy Balholm
The part being added is treated as an absolute path, because it starts with a slash, so it replaces the existing path. Andy > On Jan 31, 2017, at 2:09 PM, Manlio Perillo wrote: > > Il giorno martedì 31 gennaio 2017 18:35:02 UTC+1, Manlio Perillo ha scritto: > Thanks, I was not aware of this be

Re: [go-nuts] VERY weird timezone behavior

2017-02-04 Thread Andy Balholm
Note the date that is printed with the times. Since Jan. 1 of year zero (1 BC?) predates the establishment of standard time zones, Go converting from 1:00 PM mean solar time at Stockholm to 12:53 PM mean solar time at Berlin. (Or is the time used at Stockholm something different? It doesn’t seem

Re: [go-nuts] The feature I want most, weak *

2017-02-09 Thread Andy Balholm
Maybe you could use “notwithstanding". It’s an ignored token in the default Go compiler, and a weak pointer is one that allows an object to be freed notwithstanding any weak references to it… It’s not in the spec, though, so it might cause problems with other Go implementations such as gccgo. I

Re: [go-nuts] The feature I want most, weak *

2017-02-09 Thread Andy Balholm
I expect you’re just left with the option of magic comments then, since there’s not going to be much enthusiasm for adding a new do-nothing keyword to the language. Andy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Go -> C++ transpiler idea: Miracle child or horrible abomination?

2017-03-28 Thread Andy Balholm
If global ownership inference, with enough flexibility to replace a garbage collector, were practical, I suppose the Rust compiler would have it already. But if you want to prove the Rust developers wrong, go ahead and do it in a transpiler. Andy -- You received this message because you are s

Re: [go-nuts] [ANN] sqlite

2017-04-21 Thread Andy Balholm
As near as I can tell, this is an intermediate step in a project whose ultimate goal is to compile sqlite into Go—asm.go (a style like asm.js), apparently. Andy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] [ANN] sqlite

2017-04-25 Thread Andy Balholm
This discussion piqued my interest, and I decided to see what I could do to make rsc.io/c2go more general-purpose. My fork is at github.com/andybalholm/c2go . I think that, with appropriate .h and .cfg files, it can now handle the tests fr

Re: [go-nuts] understanding utf-8 for a newbie

2017-05-05 Thread Andy Balholm
Hexdump shows the actual bytes in the file—the UTF-8 encoding of the runes (Unicode code points). Apparently you are reading them with utf8.DecodeRune or something like that; those return the code points, without the UTF-8 encoding. Andy -- You received this message because you are subscribed

Re: [go-nuts] letsencrypt, localhost and autocert

2017-06-06 Thread Andy Balholm
What it boils down to is that your server tries to get a certificate for whatever name is in the URL. But Let’s Encrypt won’t issue a certificate for localhost, for various reasons—not the least of which is that a certificate for localhost makes as much sense as having a photo ID that says “Me”

[go-nuts] http2.Transport connections seem to occasionally get "stuck"

2017-07-05 Thread Andy Balholm
Users of github.com/andybalholm/redwood (an HTTP proxy) are running into an intermittent problem that I suspect is an HTTP/2 bug. But it is very difficult to pin down. The symptom reported by the customers is that, for an hour or two, all connections to Google servers through the proxy time out

Re: [go-nuts] slow Mod function in math/big, a better way?

2017-07-07 Thread Andy Balholm
That’s normal for languages like Python. The code that is actually running in Python is slow, but library functions are fast, because they are written in C. Andy > On Jul 7, 2017, at 4:51 AM, jeff.templon.nik...@gmail.com wrote: > > Hi > > Exploring Go, 1st project is to port over my favourite

Re: [go-nuts] slow Mod function in math/big, a better way?

2017-07-08 Thread Andy Balholm
I noticed your “naive explanation” after I sent my message. But I think it is the real explanation. Is there a better way to do it in Go? Probably not. The math/big library isn’t quite as fast as gmp, but it’s probably faster than anything you’d write yourself. If the numbers were really huge,

  1   2   >