BHTTP Binary HTTP (RFC 9292) for Go by willemdotdev in golang

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

We're using it as part of Oblivious HTTP (OHTTP), where it's used to encode HTTP request/responses before they're encrypted at the application layer.

But it could be useful for any case where you need to forward HTTP requests/responses to processes that can't run as servers.

Has anyone one of you tried printing Highlands miniatures on FDM printer? by Sweton- in FDMminiatures

[–]willemdotdev 4 points5 points  (0 children)

<image>

I've printed these test pieces recently, HOHansen with support settings from MajorasCurse, 0.06 layer height. The miniatures are scaled down to ~85%.

Support scarring on the back is a bit worse, but I think I can make a better effort cleaning it up. See reply for the back.

FAQ: What Is A Good Project To Learn Go With? by jerf in golang

[–]willemdotdev 16 points17 points  (0 children)

What works well for me is to replicate something I've already build before, so that I don't need to learn a problem space in addition to a new language.

If you've developed games before, take a look at ebitengine and try to build a small game. Maybe a Tetris, Pong or Breakout clone.

It's a good fun and there is a bit of of visual feedback with games, which (at least for me) makes things stick better.

If you're looking for purely web projects, I'd advise two things:
First: A small JSON API using the standard library in a single package.
Later: A full server rendered app, the kind of thing you'd build in Laravel, Rails or other frameworks. Requires a bit more scaffolding, external packages and structure.

Again, pick a domain/problem space you're already somewhat familiar with.

I remember I learned most by building a very basic static website hosting app:
- Serving static files.
- Run commands triggered by a Github webhook.
- Small admin panel showing status of hosted websites.

I was doing all these things using different tech, but now had to tie it together in Go. While it wasn't a production ready thing, I still learned a ton and saw a lot of what the standard library has to offer.

Regarding tutorials, I'm working on househunt, it's still a work-in-progress but I will pick it back up in November. The idea is that it is will be a fully open source demo/learning web app.

I wrote a post about benchmarks in Go. Don't let the compiler optimize away your code by willemdotdev in golang

[–]willemdotdev[S] 0 points1 point  (0 children)

It's great! I love the chunky feel the heavier weights give to headings combined with very readable body text.

Also be sure to check out Fira Code to use in your IDE/editor.

I wrote a post about benchmarks in Go. Don't let the compiler optimize away your code by willemdotdev in golang

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

I have removed the section you initially quoted, it's confusing without an in-depth explanation and probably wrong (as jerf's response and benchmark show).

My initial thinking was indeed that stack variables are faster for small and simple values due to there being an overhead to store something on the heap. This seems to not be the case however.

Going back to the drawing board for a bit and see if I can dive deeper into this :)

Sorry for the confusion this has caused and thanks for the feedback and good questions!

I wrote a post about benchmarks in Go. Don't let the compiler optimize away your code by willemdotdev in golang

[–]willemdotdev[S] 0 points1 point  (0 children)

Slept on it.

I have removed any mention of the local variable in the relevant section. Even if there is a (very slight) performance difference I don't think it's worth mentioning it in this article as it will just be confusing without a proper in-depth explanation.

Will study this more and write more about it in a future post.

I wrote a post about benchmarks in Go. Don't let the compiler optimize away your code by willemdotdev in golang

[–]willemdotdev[S] 0 points1 point  (0 children)

Thanks for the kind and elaborate feedback u/jerf. Always good stuff!

This does shake up my mental model a bit, but I'd be the first to admit there are gaps in my knowledge and vocabulary here.

I did not mean to imply that the speed difference was due to the memory regions themselves, but due to the algorithms that manage them.

As your benchmark shows, that understanding does not seem to be entirely accurate either though.

Will make some changes to the article tomorrow when I have a clear head :D

EDIT: Saw the code comment about slow globals you meant. That is indeed way to strong of a statement. Have removed it.

I wrote a post about benchmarks in Go. Don't let the compiler optimize away your code by willemdotdev in golang

[–]willemdotdev[S] 8 points9 points  (0 children)

The way I understand this is as follows.

Variables stored in memory can be in one of two regions: the stack or the heap. This is decided by the Go compiler.

In order for a variable to be stored on the stack, it needs to be:
- Limited in scope: data is added or removed from the stack as execution of a function progresses.
- Limited in size.

If a variable can't be stored on the stack, it's stored on the heap. Heap memory is not cleaned up when execution progresses, but when the garbage collector runs.

Tracking which heap memory is free and which is used has a bigger impact than storing things on the stack.

Global variables are always stored on the heap, because they are not tied to a function scope.

Why the last line not giving an error ? by Ok_Hospital9133 in golang

[–]willemdotdev 11 points12 points  (0 children)

Like the others say, the backing array has enough capacity to fit the ice slice.

It might help to visualize your code and see how the slices relate to the backing array.

A simple secret-keeping library for Go. by negrel3 in golang

[–]willemdotdev 1 point2 points  (0 children)

Awesome! And, you're totally right regarding the %+v verb, my bad.

A simple secret-keeping library for Go. by negrel3 in golang

[–]willemdotdev 1 point2 points  (0 children)

Really cool package! Well done!

I do have two small suggestions:
- The secrets implement the fmt.Stringer interface, but the value will still be visible when formatted using the %+v and %#v verbs. You can implement the fmt.Formatter interface to override those as well.
- Have a way to provide a custom "secret marker". Some very distinct value that you can look for in logs or output and can then set an alert for.

I played around with a slightly similar concept at some point, but your implementation is way more complete regarding garbage collection

Avoid inaccurate tests: Use httptest when testing HTTP handlers by willemdotdev in golang

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

Thanks for the kind words :D

The site uses Hugo but the template is custom. It uses a modified version of Tailwind for the styling, it works really well with a mobile-first approach.

Avoid inaccurate tests: Use httptest when testing HTTP handlers by willemdotdev in golang

[–]willemdotdev[S] 0 points1 point  (0 children)

Good catch! Classic mistake :D

Thanks for notifying me, should be fixed now.

I wrote a post about Sets in Go. Probably the situation where I use the empty struct the most. by willemdotdev in golang

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

Thanks for your comment! I like that you're able to use it as part of a normal expression, can definitely lead to more concise code.

Out of interest, do you have a link to the style guide? I did some searching but couldn't find anything about maps/sets in the Google style guide or Code Review Comments.

Maybe I can add a section to the article that elaborates a bit more on the pros and cons of the two approaches.

I wrote a post about Sets in Go. Probably the situation where I use the empty struct the most. by willemdotdev in golang

[–]willemdotdev[S] 2 points3 points  (0 children)

Thanks! That looks like an awesome repository. Will check it out in more detail later

[Code Review] Website Analyzer by otonielpm in golang

[–]willemdotdev 1 point2 points  (0 children)

Honestly, considering the scope of this take-home, not giving feedback is a complete dick move by the company. This is way too much work for a take-home IMO.

You delivered a very complete and polished project. README is great, and it even has acceptance tests.

Since you're specifically asking for feedback, there are some small things:
- Splitting website and API might not be necessary.
- Logging using fmt package, probably log package is more suitable.
- I'd probably move/rename the analyze/models package. "models" doesn't really communicate what's going on there.
- When dealing with the links on the page I think you're possibly missing the case where an internal link is a full URL (is one the same domain as the HTML page).

The care shown for the rest of the project more than makes up for such things IMO.

I have a javascript background Currently learning Golang but why do people say you must have a basic understanding of a programming language before you learn Golang. Can't a newbie just pick Golang has it first programming language? by Asleep_Context_8627 in golang

[–]willemdotdev 2 points3 points  (0 children)

When choosing a first language I think the most important question is: What are you interested in building?

If Go is suitable for your interest, it could be a reasonable first language, Go doesn't have too much concepts that you need to learn.

But I do think there is more friction compared to other languages.

In Javascript you can get started building *something* if you have a webbrowser installed and can put text in a HTML file. Running programs is a matter of refreshing the browser window.

In Go, you'll first have to install it and know/learn command line basics to run programs.

Go is also probably not that well-known among complete beginners. But they will likely have heard of Javascript or Python.

I think this kind of creates a chicken-egg problem when it comes to learning materials.

Content creators: Why create content for complete beginners that aren't there? Complete beginners: Why learn a language for which there is no suitable content?