fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

#cgo

2 posts2 participants0 posts today

🚀 Wow, Jim Calabro is back with a riveting tale that combines the electrifying worlds of #Go, #CGO, and Zig! 📚 Apparently, creating a *statically linked* #executable is the new extreme sport, because why settle for dynamic linking when you can spend hours trimming Zig's "excess stuff"? 🤦‍♂️🌪️
calabro.io/zig-cgo #JimCalabro #Zig #StaticallyLinked #Programming #HackerNews #ngated

calabro.ioBuilding Statically Linked Go Executables with CGO and Zig - Jim CalabroJim Calabro

Syscall и cgo в Go

Привет, Хабр! В этой статье рассмотрим работу с системными утилитами в Go. Будем напрямую общаться с ядром, дергать системные вызовы и писать код на C, чтобы Go не чувствовал себя одиноким.

habr.com/ru/companies/otus/art

ХабрSyscall и cgo в GoПривет, Хабр! Сегодня рассмотрим работу с системными утилитами в Go. Будем напрямую общаться с ядром, дергать системные вызовы и писать код на C, чтобы Go не чувствовал себя...

Демонстрация виртуального дисплея без задержки с DXGI. Или как получить второй монитор из ноутбука/телефона/планшета

Разберем несколько существующих методов захвата экрана и способы трансляции по сети с минимальной задержкой как если бы это был второй монитор подключенный к отдельному порту.

habr.com/ru/articles/873734/

#WebRTC #cgo #rtp #ip #c++ #go #directx #direct3d_11 #Desktop_duplicate_api #websocket

ХабрДемонстрация виртуального дисплея без задержки с DXGI. Или как получить второй монитор из ноутбука/телефона/планшетаВ этой статье мы разберем несколько существующих методов записи экрана и способы трансляции по сети с минимальной задержкой. Предыстория Разрабатывая продукт для саппорта появилась потребность...
Replied to Preslav Rachev

@preslavrachev
It's looking like is the main option for me to call one of my Rust libraries from a Go project.

So I'm curious about the downsides here.

The owner of the Go project won't allow CGo in their dependencies but has suggested creating a separate package and that being loaded dynamically.

I haven't done much with Go so trying to understand what I'm getting into here!

Any comment will be appreciated.

Replied to Valentin B. :ferris:

@beeb
Be interesting to compare without calling from Go. So native Go v native Rust.

Today I've been looking at using to use a Rust library of mine from a Go project, and one of the things I read was that there's a large overhead doing that. IDK what that means yet, hence my interest.

For my next trick, er project, it looks like I'm going to be playing with to call from and then have to find a way to handle the odd complex type like IO streams 😱

Nothing I ever do is straightforward. I'm the outlier of outliers... every, single, time. 🤷‍♂️

It's my own fault. I'm just a magpie coder who can't resist shiny new things.

If any of you have trodden this path before, please wave and wish me luck 😆

for

Continued thread

One of the great things about #golang is easy cross-compilation. However, most #golang #sqlite3 drivers make it considerably less easy by wrapping around the C implementation, requiring #cgo. Now there's a new `database/sql` compatible driver that gets rid of #cgo by wrapping the #sqlite #wasm build instead. Neat!

[2/2]

github.com/ncruces/go-sqlite3

GitHubGitHub - ncruces/go-sqlite3: Go bindings to SQLite using wazeroGo bindings to SQLite using wazero. Contribute to ncruces/go-sqlite3 development by creating an account on GitHub.

The #wasm build of #sqlite opens up great new possibilities in the #browser, especially when coupled with the Origin Private File System (#opfs). I've used it to implement importing huge #csv or #jsonl #datasets right in the browser. Import, validate, search, edit, close the browser and continue tomorrow, stream the database (with on-the-fly compression!) to the server when ready – it's all possible!

Another interesting use case I came across today: use it in #golang to get rid of #cgo!

[1/2]

Вызовы Си-шного кода из #Go обходятся крайне дорого, это и по замерам сродни таких тестов и по итогам реальной работы.
Как минимум в 25-26 раз дороже (а порой и в 43), чем внутри Go-шного кода вызвать Go-шную функцию.

А если вызвать Си-шный код из Go, а потом внутри этого Си-шного кода на время дёрнуть Go-шную функцию (механизм callback'ов), то это всего в 9-15 раз медленее, чем там же вызвать Си-шную функцию в пределах того же Си-шного кода.

Сказанное замерено в контексте и ver.1.21 и ver.1.22 #Golang.

Следует забыть о высоконагруженных и производительных решениях, если они постоянно вынуждены дёргать из Go-шного кода различные Си-шные функции библиотек.

Причина поста в том, что в #Go реально оптимизированы вызовы Си-шного кода лишь в контексте различных системных вызовов — которые #syscall и выполняются посредством rawSyscallNoError.
А во всех остальных случаях механизм #cgo выполняет много работы с большим количеством накладных расходов при подготовке передачи управления в Си-шный код.

#cgo #golang #programming #softwaredevelopment #softwaredev #lang_ru @Russia
hub.hubzilla.deHubzilla.de

A somewhat lengthy blog post about integration of Lua and Go (with LuaTeX) news.speedata.de/2024/02/21/mi

Mostly about creating wrapper libraries in Go and Lua to extend the functionality of the rather limited Lua standard library and its lack of Unicode handling.

news.speedata.deMixing Go and LuaThe speedata news page is about news from the speedata publisher, boxes and glue and other database publishing software
#golang#lua#cgo

Fun experiment today with #RustLang and #Golang where I checked if it would be faster to compute a large number of sha256 hashes directly in go or by using #rust one of two ways: as a statically linked library with #cgo and as a separate process using unix-domain sockets for IPC. Turns out go is always faster, with my setup around 40% (35% faster than pure rust running on its own). I benchmarked pretty much all the crates I could find for it but go's "crypto/sha256" is damn fast.