Golang

2217 readers
1 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 1 year ago
MODERATORS
76
14
submitted 1 year ago by lyda to c/golang
 
 

Wonder if anyone here has been using bingo for reproducible builds. I've found it to be really good and wish I could find similar tooling for things like python for tools like yamllint.

77
11
Memoization in Go (en.wikipedia.org)
submitted 1 year ago by lyda to c/golang
 
 

I'm curious what people are doing for memoization in #golang. I've looked around and haven't found great libraries for this which makes me wonder if I'm pursuing the wrong solution to a problem.

Caching the return values of functions based on the params has been useful to reduce load on downstream services, make things a bit faster on average and even add some level of consistency in functions that can be highly variable (which is an odd use case but nonethelass useful). But maybe there's a different pattern/idiom that's used in the Go ecosystem?

78
 
 

Did I break a taboo by doing this?

79
80
81
82
 
 

Go 1.21 adds a new port targeting the WASI preview 1 syscall API through the new GOOS value wasip1. This port builds on the existing WebAssembly port introduced in Go 1.11.

WebAssembly (Wasm) is a binary instruction format originally designed for the web. It represents a standard that allows developers to run high-performance, low-level code directly in web browsers at near-native speeds.

Go first added support for compiling to Wasm in the 1.11 release, through the js/wasm port. This allowed Go code compiled using the Go compiler to be executed in web browsers, but it required a JavaScript execution environment.

As the use of Wasm has grown, so have use cases outside of the browser. Many cloud providers are now offering services that allow the user to execute Wasm executables directly, leveraging the new WebAssembly System Interface (WASI) syscall API.

83
84
 
 

Hey! I've just published a new blog about how I improved consistency and performance in a @golang crawler with retry logics and network tuning.

https://blog.maxgio.me/posts/improving-consistency-performance-go-crawler-retry-logics-http-client-tuning/

85
 
 

Hello Lemmy,

Bluetuith is a TUI based bluetooth manager for Linux, that aims to be an alternative to most bluetooth managers, and can perform bluetooth based operations like:

  • Connection to and general management of bluetooth devices, with device information like battery percentage, RSSI etc. displayed, if the information is available. More detailed information about a device can be viewed by selecting the 'Info' option in the menu or by clicking the 'i' key.

  • Bluetooth adapter management, with toggleable power, discoverability, pairablilty and scanning modes.

  • Transfer and receive files via the OBEX protocol, with an interactive file picker to choose and select multiple files.

  • Handle both PANU and DUN based networking for each bluetooth device

  • Control media playback on the currently connected device, with a media player popup that displays playback information and controls.

This release contains the following new features:

  • Adapter status display, which will dynamically show whether the adapter is in any of the powered/discoverable/pairable/scanning states

  • A HJSON based configuration format, with customizable keybindings and optional config file generation

  • Popup resize and mouse-handling improvements. Each popup can now be closed by pressing the 'X' button

I hope you enjoy this release, and any feedback is appreciated.

86
 
 

Hi,

is there a way to use MongoDB query syntax or something similar to filter arrays/slices or validate data in Go?

In (node)JS there's Sift.js or (less MongoDB style) Underscore/lodash.

Possible use cases:

  • Easily readable validation syntax (at least for people knowing MongoDB)
  • mocking a MongoDB for dev purposes
  • filtering arrays/slices more easily

I'm relatively new to Go so maybe there already is a best practice to do stuff like that, I don't know of.

87
 
 

Cgo calls take about 40ns, about the same time encoding/json takes to parse a single digit integer. On my 20 core machine Cgo call performance scales with core count up to about 16 cores, after which some known contention issues slow things down.

88
 
 

So nice to finally have this built into toolchain.

89
9
submitted 1 year ago by SystemOut to c/golang
90
 
 

In this article, I'll describe how to organize protobuf files messages and gRPC services in the Go sources. I'll briefly examine how to use protoc and plugins with the proper imports, and project structure.

91
17
submitted 1 year ago by nebiros to c/golang
92
93
 
 

The new log/slog package in Go 1.21 brings structured logging to the standard library. Structured logs use key-value pairs so they can be parsed, filtered, searched, and analyzed quickly and reliably. For servers, logging is an important way for developers to observe the detailed behavior of the system, and often the first place they go to debug it. Logs therefore tend to be voluminous, and the ability to search and filter them quickly is essential.

94
 
 

While writing Go, you might might run into the following situation: You want to collect the results of a function in a slice. However, the function returns a pointer.

You might then ask yourself:

What kind of slice should I use? A slice of values or a slice of pointers?

Let’s make this a bit more concrete.

95
 
 

Not a hard question. It’s sum types! (Or enums, tagged unions, or whatever you want to call them).

96
29
Scripting with Go (bitfieldconsulting.com)
submitted 1 year ago by nebiros to c/golang
 
 

In this article we’ll explore a package called script that aims to sprinkle some Unix shell fairy dust on your Go programs.

97
 
 

Boring is good. Boring is stable. Boring means being able to focus on your work, not on what’s different about Go. This post is about the important work we shipped in Go 1.21 to keep Go boring.

There will not be a Go 2 that breaks Go 1 programs. Instead, we are going to double down on compatibility, which is far more valuable than any possible break with the past. In fact, we believe that prioritizing compatibility was the most important design decision we made for Go 1.

98
99
20
Rust vs Go in 2023 (self.golang)
submitted 1 year ago by nebiros to c/golang
 
 

Rust vs Go in 2023

Which is better, Rust or Go? Go or Rust? Which language should you choose for your next project in 2023, and why? How do the two compare in areas like performance, simplicity, safety, features, scale, and concurrency? What do they have in common, and where do they fundamentally differ? Let’s find out, in this friendly and even-handed comparison of Rust and Golang.

100
 
 

Is Go 1.21 already on your upgrade list? It should be!

In the tradition of Go, release 1.21 does not deliver loads of new language features but many improvements to the toolchain and the ecosystem.

view more: ‹ prev next ›