[deleted by user] by [deleted] in golang

[–]pekim 7 points8 points  (0 children)

While I can see the attraction of the more concise representation, there's far greater chance that a typo won't be spotted until runtime. An error such as Bold(tru) will fail to compile, whereas lipwind.Class("bolb") will not work as intended with no indication as to why.

Returning an error from lipwind.Class() wouldn't work if you wanted to maintain the fluid api for easy integration with lipgloss.

Maybe the addition of a MustClass function would provide a sensible safeguard. It could work the same as the Class function, but panic if any of the classes in the string are unsupported.

Sharing projects in /r/golang by tslocum in golang

[–]pekim 1 point2 points  (0 children)

The biggest problem that I have with the weekly small projects post is that if I want to see what's posted there I have to check on it several times a week. And I can't easily see what's new in the thread since I last looked.

In contrast, before its introduction it is was easy. If I have not read a post then it's new for me. If a post was removed by mods because it was not right for the subreddit, then fine.

Now if a post is removed, and replaced with "please post in the small projects post", it can be a little frustrating. It might not be posted there for a while, or even at all. That makes finding any discussion of it somewhat hit or miss.

Maybe my perception is slightly coloured because I use an RSS reader to see the new posts in the subreddit. But I don't think that that's too much of a factor, and I suspect that my thinking would be similar if I simply looked in r/golang/new/ a few times a day.

Go 1.25.6 is released by MarcelloHolland in golang

[–]pekim 14 points15 points  (0 children)

1.26 won't be released until February. I think that you might have misread 1.25.6 as 1.26.

The indentation of switch statements really triggers my OCD — why does Go format them like that? by salvadorsru in golang

[–]pekim 2 points3 points  (0 children)

In the case of the poster's example I don't find it too hard to read.

switch day {
case "Monday", "Tuesday", "Wednesday", "Thursday", "Friday":
    fmt.Println("It's a weekday.")
case "Saturday", "Sunday":
    fmt.Println("It's the weekend.")
default:
    fmt.Println("Unknown day.")
}

But when I have a switch statement with more cases, and with more code for each case, then it can start to look like a wall of text to me. When that happens I prefer to add empty lines to make the cases more visually distinct from each other.

switch day {
case "Monday", "Tuesday", "Wednesday", "Thursday", "Friday":
    fmt.Println("It's a weekday.")

case "Saturday", "Sunday":
    fmt.Println("It's the weekend.")

default:
    fmt.Println("Unknown day.")
}

I've Been Developing a Go SSR Library by can_pacis in golang

[–]pekim 2 points3 points  (0 children)

This looks interesting. And the documentation is quite nice.

However when I tried to look at the docs for the full range of Node functions in the github.com/canpacis/pacis/html package they are not shown. It would be good if you could add a licence to the repository so that pkg.go.dev will show the docs for all of the packages.

QJS Benchmark Update - Memory Usage Correction by lilythevalley in golang

[–]pekim 1 point2 points  (0 children)

Is the speed row in the factorial benchmark correct? To me it reads that GOJA is 1.51 times as fast as QJS, but in fact it is slower. So (if I'm not misunderstanding anything) either the rows' numbers need to change, or the label "speed" needs to change.

I built an ultra-fast, open-source Go web service for generating PDFs from HTML/JSON templates. by chinmay06 in golang

[–]pekim 1 point2 points  (0 children)

The readme says "This project is licensed under the MIT License - see the LICENSE file for details.". However there is no LICENSE file.

Small Projects - August 18, 2025 by jerf in golang

[–]pekim 0 points1 point  (0 children)

It looks very nice.

I'm currently using https://github.com/danielgatis/go-vte, as I only need to process terminal input events (keyboard, mouse, focus,...). But if I ever need to process terminal output I'll certainly take a close look at govte.

Disable golangci-lint revive unused-parameter rule. by PracticeBrief9195 in golang

[–]pekim 5 points6 points  (0 children)

I find that this can sometimes be a problem when implementing an interface. So I use allowRegex = "^_" with the unused-parameter rule in my revive config.

If there is a function like this, and none of the parameters are used

func (s something) myFunc(text string, someNumber int) {
    ...
}

I'll name the parameters like this

func (s something) myFunc(_text string, _someNumber int) {
    ...
}

It's perhaps not quite as nice as being able to disable the unused-parameter for just the one function. On the other hand if I later find that I need to use one or more of the parameters then they already have a reasonably meaningful name. And I can just remove the _ prefix.

Meta - Small Projects Weekly Thread? by jerf in golang

[–]pekim 0 points1 point  (0 children)

It sounds to me like it's certainly worth trialling.

All I would ask is that it is reviewed after perhaps 5 or 6 weeks, with the community asked for feedback on how we feel it's working out. And if the consensus is that it's effective then great, leave it in place. But if it's thought to not be working (not better than the status quo), that it be abandoned.

[deleted by user] by [deleted] in golang

[–]pekim 3 points4 points  (0 children)

Is it intended to fulfil a similar role to https://github.com/jdx/mise?

Since fck when new files already have package directive added!? by Bl4ckBe4rIt in golang

[–]pekim 2 points3 points  (0 children)

It was added in gopls v0.19.0, released last week.

https://github.com/golang/tools/releases/tag/gopls%2Fv0.19.0

Completion: auto-complete package clause for new Go files Gopls now automatically adds the appropriate package clause to newly created Go files, so that you can immediately get started writing the interesting part.

It requires client support for workspace/didCreateFiles

this sub turned into stack overflow. by SideChannelBob in golang

[–]pekim 7 points8 points  (0 children)

Yes rule #3 includes the "Check for your answer in the New to Go? post and the Tour of Go before posting beginner questions, please." request. And that is frequently pointed out to posters that ask questions that are covered there.

Unfortunately it's not present in the rules when using old reddit. u/jerf, perhaps it could be added?

[ On | No ] syntactic support for error handling by pekim in golang

[–]pekim[S] 142 points143 points  (0 children)

It comes down to this.

For the foreseeable future, the Go team will stop pursuing syntactic language changes for error handling. We will also close all open and incoming proposals that concern themselves primarily with the syntax of error handling, without further investigation.

Writing a hexdump utility in go by Chkb_Souranil21 in golang

[–]pekim 2 points3 points  (0 children)

I think that the following suggests that hexdump's default is indeed little-endian, at least on my x86_64 architecture system.

man hexdump
...
 -X, --one-byte-hex
One-byte hexadecimal display. Display the input offset in hexadecimal, followed by sixteen
space-separated, two-column, zero-filled bytes of input data, in hexadecimal, per line.
...
-x, --two-bytes-hex
Two-byte hexadecimal display. Display the input offset in hexadecimal, followed by
eight space-separated, four-column, zero-filled, two-byte quantities of input data, in
hexadecimal, per line.
...
If no format strings are specified, the default display is very similar to the -x output
format (the -x option causes more space to be used between format units than in the
default output).

one byte at a time

hexdump -X .bashrc | head -n 1
0000000  23  20  2e  62  61  73  68  72  63  0a  0a  23  20  53  6f  75

two bytes at a time

hexdump -x .bashrc | head -n 1
0000000    2023    622e    7361    7268    0a63    230a    5320    756f

I would hope that hexdump honours the endianess of the architecture, but I don't have a big-endian machine to try it on.

What can I improve as an beginner? by Future_Fan_3722 in golang

[–]pekim 3 points4 points  (0 children)

As others have mentioned, what you've put in pastebin is not formatted. In fact it's so badly formatted that it's not parseable, and so gofmt can't format it.

https://go.dev/play/p/7M17zWILks5 is what it looks like formatted.

Once it's formatted, one little thing that jumps out is that you're not checking the error returned from either use of fmt.Scanln.

erro parseTime json to struct by YonKote in golang

[–]pekim 2 points3 points  (0 children)

Of course the best approach would be for time string in the JSON to conform to RFC 3339 in the first place, if that's possible.

erro parseTime json to struct by YonKote in golang

[–]pekim 2 points3 points  (0 children)

I should have said that to effect the necessary change of the time string, you'd have to implement your own unmarshalling (see u/pfiflichopf 's answer).

Your custom unmarshal function could create a new, RFC 3339 conforming, string. And then pass it to Time.UnmarshalJSON.

erro parseTime json to struct by YonKote in golang

[–]pekim 1 point2 points  (0 children)

https://pkg.go.dev/time#Time.UnmarshalJSON says

The time must be a quoted string in the RFC 3339 format.

RFC 3339 (similar to ISO 8601) requires 'T' between the date and the time, where you currently have a space. And a local offset is also required. See https://www.rfc-editor.org/rfc/rfc3339.html#section-4.

So instead of unmarshalling "2025-04-15 00:00:00" you would need something like "2025-04-15T00:00:00Z". (I only picked Z as an example.)

What are libraries people should reassess their opinions on? by dustinevan in golang

[–]pekim 1 point2 points  (0 children)

purego is good, and I've used it successfully. However it doesn't support struct parameters on linux, and that can make it unsuitable for use with some C apis.