golang

carapace,
@carapace@mastodon.social avatar

Is this a bug in Go's regexp package? This program should print false instead it prints true:

package main

import (
"fmt"
"regexp"
)

func main() {
r := regexp.MustCompile("^1|0$")
fmt.Printf("%v\n", r.MatchString("00"))
}

I checked against Python's re module and it works as expected:

>>> import re
>>> r = re.compile('^1|0$')
>>> print(r.match('00'))
None

#go #golang #google

eob,
@eob@social.coop avatar

@carapace Maybe your regex is being interpreted as

(^1)|(0$)

So it matches anything beginning with 1 or ending with 0

if you change it to

^(1|0)$

does that work as you expect to match either a single 0 or 1?

alyx, French
@alyx@3615.computer avatar

Je vais ptete reprendre un peu le stream pour des jeux vidéos et du développement en . Je vais essayer Owncast en rentrant, ça peut être sympa et moins me faire peur que Twitch. Des conseils pour utiliser Owncast ?

alyx,
@alyx@3615.computer avatar

@Thomas trop trop cool @tournesol, t'as toujours une longueur d'avance ! 🩷

tournesol,
@tournesol@peculiar.florist avatar

@alyx @Thomas arrête c'est toi ​:neocat_melt_sob_heart:​

Honnêtement leur doc est assez complété, juste si t'active la fédération, il a fallu attendre une quinzaine de minutes pour trouvée l'instance owncast sur fedi

kali,
@kali@cyberpunk.lol avatar

hey @vantablack are bots allowed on cyberpunk.lol? like if i wanted to host a fork of @yuribot that posts femboys... would that be allowed?

im open to slowing down the time between posts and stuff like that, and it wont be ready immediately coz i know jack about and im no expert at bot development

if not all good, im already in the process of making a BotsIn.Space account

vantablack,
@vantablack@cyberpunk.lol avatar

@kali probably better for it on botsin.space tbh c: but best of luuuuck!!!

kali,
@kali@cyberpunk.lol avatar

@vantablack ill do it there then 🖤 thanks

outsidecontext,
@outsidecontext@fosstodon.org avatar

As part of some side project using I implemented the musicbrainzws2 package. It wraps the web service and search API into a Go friendly interface.

The package is I think rather feature complete, but likely there are bugs and in the current state I reserve the freedom to change the interface at any time as I see fit. But maybe you want to give it a try if you need to access the MB API with Go.

https://pkg.go.dev/go.uploadedlobster.com/musicbrainzws2

ks982579,
@ks982579@techhub.social avatar

Level up your programming skills with Go! ⏫

My main focus for my Master's in Computer Science has been on Rust, but I'm always looking to expand my skillset. That's why I'm excited to dive into the Golang Programming bundle by hashtag on Humble Bundle. This bundle offers a great opportunity to learn Golang, a powerful open-source language gaining traction in the tech industry. I'm particularly interested in the "Go Programming - Beginner to Professional" book, which seems like a perfect starting point for anyone new to Go, like myself.

Is anyone else exploring Golang?

Feel free to share your experiences or learning resources in the comments below!

https://www.humblebundle.com/books/golang-programming-packt-books

buherator,
@buherator@infosec.place avatar

This latest writeup by @joern mentions the of Go’s filepath.Clean is “not really obvious” when dealing with relative paths.

I think this is something all devs should be aware of to avoid similar vulnerabilities.

The language is kind of amazing:

  • Step 3. only applies if there is a parent path to be eliminated together with the subsequent “..” (“/foo/..” -> “/“)
  • Step 4. only applies to “rooted” (absolute) paths, so “/../foo” would become “/foo”, but “../“ is left untouched (as there is no relative parent path to eliminate either).

This makes the docs technically correct (“the best kind of correct!”), but even with the solution at hand it took some head scratching to figure out the true meaning.

excds,
@excds@berlin.social avatar

For a work project it seems we will have to implement a library for building/evaluating ODRL statements. Since I haven't previously started such a parser library project, I would like suggestions on projects I could look at for inspiration in

  • Ease of use in interfaces
  • Test structure
  • Generally nice code

Please post links to projects you think are nice to use. Oh, and please boost for bigger reach.

mackuba,
@mackuba@martianbase.net avatar

It's insane that I can have a conversation with this thing and in a few moments and a few back and forths build a working program in a language I know nothing about (I don't know Go)… don't tell me this isn't huge 😳

You: One modification - this current code counts all matches of all regexps against the text. So if one line of text matches two or more regexps, it will be counted as 2 or more. I want a given line of text to only be counted once if it matches
You: What's the command to compile this to a binary? ChatGPT: To compile a Go program to a binary, you can use the go build command followed by the name of the Go file you want to compile. If you want to specify the output binary name, you can use the -o flag followed by the desired name. Assuming your Go file is named main.go, you can compile it to a binary named my_program like this: You: Looks like
You: Great, that works 👍 Is there some way to compile this program in "release mode", with a more optimized version or something? ChatGPT: Yes, you can compile your Go program in release mode with optimizations using the go build command with the -ldflags flag set to -s -w, and the -trimpath flag set to remove the build path from the resulting binary. Here's the command to compile your program in release mode: You: I mean, not optimizations for binary size, but optimizations to make it faster? ChatGPT: Ah, I see! In Go, optimization for speed primarily comes from the compiler's default optimizations, and there isn't a direct flag to enable additional optimizations beyond what the compiler already does. However, there are some general principles you can follow to improve the performance of your Go program: Profiling: Use Go's profiling tools (go test -cpuprofile, go tool pprof, etc.) to identify bottlenecks in your code and optimize them. Profiling helps you understand (…)

ahapen,
@ahapen@mas.to avatar

@mackuba No, it isn't. No wonder the quality of software is getting worse and worse.

mackuba,
@mackuba@martianbase.net avatar

@ahapen Well, I'm sure that my first ever program in Go would be of much better quality if I wrote it completely by myself…

markus,
@markus@hachyderm.io avatar

I released a new version of my module for persistent message queues based on today. I added a basic job runner, since that’s one of the things I most use a queue for. Check it out at https://www.goqite.com

fallenhitokiri,
@fallenhitokiri@social.screamingatmyscreen.com avatar

Bubble Tea for is the first TUI library I touched that doesn’t make me regret writing a TUI.

The examples, documentation and video tutorials also make it super easy to get started or stitch together the parts you need.

Overall this is just a really good library from a developer perspective.

rsc,
@rsc@hachyderm.io avatar

“Evolving the Go Standard Library with math/rand/v2”
https://go.dev/blog/randv2

Ant8e,
@Ant8e@fosstodon.org avatar

Probably what go should have been in the first place

https://borgo-lang.github.io/#intro

guardianproject,

's core crypto/tls library merged client support! It should be included in the Go v1.23 release. Server-side support is still in the works.

https://go-review.googlesource.com/c/go/+/578575

alyx,
@alyx@3615.computer avatar

I'd like to find more YouTube channels about software development / engineering / etc but it's like 98% of the same white guy, screaming like a twitch streamer, making almost every video about "this is X killer" "why you should NEVER do that" or "your IDE is shit use X instead". Of course they talk like they are the thing and it's the only truth.

Any recommendations? interested in or anything related

alyx,
@alyx@3615.computer avatar

It makes me wonder also: are they popular because they are matching the YouTube format expectation (fast cut, loud voice, 10000% sure about everything, shiting on anything else) or because the community is just like them?

Thanks god, https://www.youtube.com/@bashbunni/ exists (cc @charmcli if she can read that account haha)

zethtren,
@zethtren@mastodon.social avatar

@alyx Code to the Moon, Code Aesthetic, Dreams of Code, ArjanCodes, Low Level Learning, Backend Banter, mCoding, Chris Biscardi, Jeremy Chone, Jon Gjengset, No Boilerplate, HyperNeutrino, and Logan Smith are a few of the ones I subscribe too. (Left the 5-6 “hype” devs I watch out of the list for you.)

I find it’s better to subscribe to a LOT of slow release channels. I get a consistent feed of good quality that way. 🙂

wilson,

This weekend, I hacked together a markdown documentation generator for Postgres in Go. It should be extensible to other databases, as well as including other properties from database.

It's called SQLDoc — please check it out!

https://husin.dev/sqldoc/

mid_kid,
@mid_kid@fosstodon.org avatar

Downloading 300MB+ of dependencies for a single program like disk space don't matter 😎

visone,
@visone@fosstodon.org avatar

@mid_kid
At least it's a go one, imagine if it were in rust...xddddd

alrs,
@alrs@lsngl.us avatar
christophberger,
@christophberger@c.im avatar

Is a-h/templ overrated? What's your opinion?

I stumbled upon this (sometimes heated) discussion:

https://www.reddit.com/r/golang/comments/1c8l8ux/templ_is_overhyped_have_you_even_tried_it/

Some love Templ, some say its DX leaves a lot to be desired. Some miss the field-tested templating engines of other languages.

Curious:

  1. What is your favorite Go templating engine?

  2. What is your favorite Go templating engine if you want type safety in your templates?


https://www.reddit.com/r/golang/comments/1c8l8ux/templ_is_overhyped_have_you_even_tried_it/

preslavrachev,
@preslavrachev@mastodon.social avatar

@christophberger I used templ to demo a small thing last year. To me, it’s about as useful as sqlc - while I absolutely love the safety and code generation aspect of both, each adds its own level of overhead that I don’t think I enjoy.

That said, the only thing I miss from the stdlib’s template engine is the ability to hierarchically compose templates (which I doubt we’ll ever get). I have previous experience with Django, so I found the Pongo2 lib a good fit too. So, one of those two.

watzon,
@watzon@watzonmanor.com avatar

Ok peeps, we're 4 months into 2024 and I've been without work this whole time so we're going to try this again. If you know of any senior software engineering positions that are actually being hired for, please drop them below.

I have 12 cumulative years of experience, so that shouldn't be an issue, and I know most of the languages in use nowadays well enough to be dangerous, but I am extremely proficient in TypeScript, Python, and Ruby. What I'd rather do more than anything though is have an opportunity to use Go professionally.

stefano,
@stefano@bsd.cafe avatar

Interesting reading: Go performance from version 1.0 to 1.22

https://benhoyt.com/writings/go-version-performance-2024/

#go #golang #programming #performance

levlaz,
@levlaz@hachyderm.io avatar
snonux,
@snonux@fosstodon.org avatar

Go enums s***k, let's make better ones https://buff.ly/3PsEfbQ

snonux,
@snonux@fosstodon.org avatar

@orsinium looks neat. Thanks for sharing. Looks like a good use of generics, too

preslavrachev,
@preslavrachev@mastodon.social avatar

@snonux @orsinium it is a neat approach, indeed. However, those checks, whether a value is a member of the enum are no fun, IMO. It’s just way too easy to forget to do it.

I’m wondering if there’s a way to get some security during development. If there were a golangci-lint check that would scream of one tried to create a new value outside the package of the enum, that’d be a good start, I think.

jamesog,
@jamesog@mastodon.social avatar

Crimes against humanity: I just came across an (internal) repo that has a go.mod templated using ERB

jamesog,
@jamesog@mastodon.social avatar

@jippi @wader Salt is equally guilty, if not more so, of that

jippi,
@jippi@expressional.social avatar

@jamesog @wader I managed to dodge all salt usage, so never had hands on with it - ansible was plenty all that for my liking lol

purelinux, German
@purelinux@social.tchncs.de avatar

Whats your favorite #Go #webframework ? And why?

#golang

purelinux,
@purelinux@social.tchncs.de avatar

Asking, cause i am currently rewriting my website. Originally, the new site is based on . So today, i enhanced it with an written in and ... contact form and stuff.

But i am wondering, whether theres may be an out there, that can cover the jekyll part ( features).

I am quite new to , which is why i am quite unsure, what to use.

ubo,
@ubo@social.tchncs.de avatar

@purelinux Not sure, what you are looking for. Is it https://gohugo.io/ ?

alyx,
@alyx@3615.computer avatar

What’s your favorite library in for web authentication? Or any other recommendation to implement it (like std lib or just a JWT one etc).

Ideally it supports classic credentials, 2FA and passkeys. Bonus for OAuth providers that you can extend (if it does not support Mastodon out of the box for example).

Reboost welcome 👉👈

jtom38,

@alyx if you are unable to find the issue I can take a peek and see if I find the jwt issue. Just let me know and good luck!

alyx,
@alyx@3615.computer avatar

@jtom38 we could peer review what we built each other, like it we were serious cybersecurity professionals 😂

  • All
  • Subscribed
  • Moderated
  • Favorites
  • golang
  • DreamBathrooms
  • magazineikmin
  • cubers
  • everett
  • rosin
  • Youngstown
  • ngwrru68w68
  • slotface
  • osvaldo12
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • khanakhh
  • megavids
  • GTA5RPClips
  • normalnudes
  • thenastyranch
  • mdbf
  • ethstaker
  • modclub
  • Leos
  • tester
  • provamag3
  • cisconetworking
  • anitta
  • JUstTest
  • lostlight
  • All magazines