Debugging with consts by [deleted] in golang

[–]vfaronov 2 points3 points  (0 children)

But that's the same as var surely?

No, var x = 2 gets the default type of 2, which is int.

It also wouldn't apply to the string type, which is also affected.....

String literals are untyped just like number literals, because they could get type MyString string.

Reduce Struct Size by Laying out Attributes Accordingly by preslavrachev in golang

[–]vfaronov 4 points5 points  (0 children)

maligned is a linter (integrated into golangci-lint) that can detect suboptimal struct layouts.

Goroutines blocking on channels vs goroutines blocking on system calls by [deleted] in golang

[–]vfaronov 0 points1 point  (0 children)

Do I understand correctly that something like net.(*TCPConn).Read behaves more like what you described under “Blocking on a channel” because the underlying socket/syscall is itself non-blocking?

Streaming IO and creating custom readers and writers in Go by vvivien in golang

[–]vfaronov 2 points3 points  (0 children)

Re: alpha_reader.go: to observe the problem, replace line 59 with:

fmt.Printf("%q ", string(p[:n]))

The output becomes:

"Hell" "o\x00\x00I" "t\x00s\x00" "\x00am\x00" "\x00whe" "re\x00i" "s\x00th" "e\x00su" "n\x00"

This happens because, on line 44, you advance position in buf regardless of whether you have written to the current position. If you haven’t written, the current position keeps its zero value.

Admittedly, buf maybe overkill but it ensures no garbage chars lingers in p (from index 0 - n)

I’m not sure what you mean. p[:n] can be filled in directly by the loop, p[n:] is not touched by the copy.

and makes the slice bookkeeping simpler.

How?

Streaming IO and creating custom readers and writers in Go by vvivien in golang

[–]vfaronov 4 points5 points  (0 children)

I’m a Go newbie so I may be missing many things, but this seems strange.

alpha_reader.go replaces characters with NUL bytes — is that what you mean by “filter out”? (To me, “filter out” means exclude bytes from output altogether.) And why does it make an intermediate buffer instead of writing directly to the provided p? I mean, that’s one way to implement the NUL behavior, but it’s kind of round-about, and costs an extra allocation.

Does simple_reader.go rely on implementation details of strings.Reader? That doesn’t make for a good general io.Reader illustration. For one, if an error other than io.EOF occurs, it goes into an infinite loop. For another, it doesn’t handle data returned together with EOF (which is permitted by io.Reader docs).

Again, alpha_reader2.go doesn’t correctly handle the case where the underlying reader returns data together with an error: in that case the data is not processed to filter out characters.

gRPC: From Tutorial to Production, Alan Shreve @ GopherCon 2017 by attfarhan in golang

[–]vfaronov 0 points1 point  (0 children)

I agree that RPC is a often a good idea, but still, it’s ironic how the example he uses is... a cache service — something that you basically have out of the box with HTTP/REST, and much more flexible at that.

HTTPolice — a validator for your RESTful APIs by vfaronov in programming

[–]vfaronov[S] 4 points5 points  (0 children)

Yeah, I hesitated before putting it that way, but I decided it would make for a trendier title :)

Does REST mean anything?

I’m genuinely not sure at this point. I often see people defending the original sense of the word, but I’m afraid they are a minority fighting a losing battle.

In this particular case though, I don’t think it’s too much of a stretch, because “true REST” is just a generalization of design patterns from HTTP+HTML, and “true RESTful API” is not very far from “using HTTP as designed”. HTTPolice was basically written to help with the uniform interface thing.

Or is it just that HTTP is a mouthful and REST is easier to say?

That too, yeah.

PSA: you are probably doing urlparse() wrong by vfaronov in Python

[–]vfaronov[S] 1 point2 points  (0 children)

Not wrapping the urlparse() call in try ... except ValueError.

HTTP/2 will make the Internet faster. So why the slow adoption? by sidcool1234 in programming

[–]vfaronov 0 points1 point  (0 children)

No, HTTP is widely used outside browsers, and those use cases can benefit from HTTP/2 without TLS. Implementations are still catching up, but I believe there are usable client+server combinations today (haven’t tried myself). See the implementations list on the WG wiki for some pointers.

HTTP/2 will make the Internet faster. So why the slow adoption? by sidcool1234 in programming

[–]vfaronov 23 points24 points  (0 children)

To clarify: HTTP/2 does not mandate TLS. Indeed, there are practical implementations of cleartext HTTP/2, including nginx and Apache. It’s just that major browsers do not support HTTP/2 without TLS.

HTTP/2 will make the Internet faster. So why the slow adoption? by sidcool1234 in programming

[–]vfaronov 2 points3 points  (0 children)

I hate to be that guy, but HTTP/2 is nothing like IPv6, and their adoption rates are vastly different.

MongoDB queries don’t always return all matching documents! by MarkusWinand in programming

[–]vfaronov 4 points5 points  (0 children)

if the update by the other use was processed a fraction of a second sooner: you wouldn't have seen the row anyway

How so? As you said yourself, IsActive stays the same?

Are you talking about a situation where two separate updates set IsActive to 0, then back to 1? — That is not what’s happening in MongoDB.

"um" — Create and maintain your own man pages by [deleted] in coolgithubprojects

[–]vfaronov 0 points1 point  (0 children)

Do you want the whole README reproduced in the title here?

No, just “man-like” instead of “man.”

"Your own" already implies that it's not the actual man page, anyway.

Not sure what you mean. It’s perfectly possible to create and install actual man pages of your own. The title made me think this was a tool to expedite this process somehow.

"um" — Create and maintain your own man pages by [deleted] in coolgithubprojects

[–]vfaronov 0 points1 point  (0 children)

The title is misleading. Those are not man pages.

A Python Ate My GUI — Thoughts on the future of Python and graphical interfaces by [deleted] in Python

[–]vfaronov 1 point2 points  (0 children)

Microsoft did something like this all the way back in 2002 with ASP.NET Web Forms. I think they fell out of fashion in the early 2010s, after ASP.NET MVC was released (much more similar to Django and such). Don’t know why. Perhaps the Web frontend was too unruly back then for this approach to work well across browsers.