5 分鐘搞定 Go 自定義結構體標籤
本文介紹瞭如何通過自定義結構體標籤實現對結構體字段值的自定義處理,並討論了該方法的優缺點。原文:Struct Tags in Go: Implementing Custom Tag Functionality[1]Go 的 struct 標籤提供了一種爲 struct 字段定義元數據的方法,允許開發人員指定在序列化或驗證等操作期間如何處理這些字段。一個常見用例是 json 標籤,告訴 Go 的 ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:1383 ARCHIVED:87781 CACHE:2688 FOLLOWERS:22 FOLLOWING:14
We’re entering the “too hot to think”-season in 3, 2, 1 … and we’re live!
🧮 USERS:1 FEEDS:2 TWTS:1382 ARCHIVED:87766 CACHE:2684 FOLLOWERS:22 FOLLOWING:14
I did a “lecture”/“workshop” about this at work today. 16-bit DOS, real mode. 💾 Pretty cool and the audience (devs and sysadmins) seemed quite interested. 🥳
- People used the Intel docs to figure out the instruction encodings.
- Then they wrote a little DOS program that exits with a return code and they used uhex in DOSBox to do that. Yes, we wrote a COM file manually, no Assembler involved. (Many of them had never used DOS before.)
- DEBUG from FreeDOS was used to single-step through the program, showing what it does.
- This gets tedious rather quickly, so we switched to SVED from SvarDOS for writing the rest of the program in Assembly language. nasm worked great for us.
- At the end, we switched to BIOS calls instead of DOS syscalls to demonstrate that the same binary COM file works on another OS. Also a good opportunity to talk about bootloaders a little bit.
- (I think they even understood the basics of segmentation in the end.)
The 8086 / 16-bit real-mode DOS is a great platform to explain a lot of the fundamentals without having to deal with OS semantics or executable file formats.
Now that was a lot of fun. 🥳 It’s very rare that we do something like this, sadly. I love doing this kind of low-level stuff.
🧮 USERS:1 FEEDS:2 TWTS:1381 ARCHIVED:87759 CACHE:2692 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1380 ARCHIVED:87754 CACHE:2699 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1379 ARCHIVED:87753 CACHE:2701 FOLLOWERS:22 FOLLOWING:14
On my blog: Free Culture Book Club — First Woman — Dream to Reality https://john.colagioia.net/blog/2025/06/21/first-woman-1.html #freeculture #bookclub
Saw this on Mastodon:
https://racingbunny.com/@mookie/114718466149264471
18 rules of Software Engineering
- You will regret complexity when on-call
- Stop falling in love with your own code
- Everything is a trade-off. There’s no “best” 3. Every line of code you write is a liability 4. Document your decisions and designs
- Everyone hates code they didn’t write
- Don’t use unnecessary dependencies
- Coding standards prevent arguments
- Write meaningful commit messages
- Don’t ever stop learning new things
- Code reviews spread knowledge
- Always build for maintainability
- Ask for help when you’re stuck
- Fix root causes, not symptoms
- Software is never completed
- Estimates are not promises
- Ship early, iterate often
- Keep. It. Simple.
Solid list, even though 14 is up for debate in my opinion: Software can be completed. You have a use case / problem, you solve that problem, done. Your software is completed now. There might still be bugs and they should be fixed – but this doesn’t “add” to the program. Don’t use “software is never done” as an excuse to keep adding and adding stuff to your code.
🧮 USERS:1 FEEDS:2 TWTS:1378 ARCHIVED:87729 CACHE:2694 FOLLOWERS:22 FOLLOWING:14
@aelaraji@aelaraji.com I use Alt+. all the time, it’s great. 👌
FWIW, another thing I often use is !! to recall the entire previous command line:
$ find -iname '*foo*'
./This is a foo file.txt
$ cat "$(!!)"
cat "$(find -iname '*foo*')"
This is just a test.
Yep!
Or:
$ ls -al subdir
ls: cannot open directory 'subdir': Permission denied
$ sudo !!
sudo ls -al subdir
total 0
drwx------ 2 root root 60 Jun 20 19:39 .
drwx------ 7 jess jess 360 Jun 20 19:39 ..
-rw-r--r-- 1 root root 0 Jun 20 19:39 nothing-to-see
🧮 USERS:1 FEEDS:2 TWTS:1377 ARCHIVED:87719 CACHE:2687 FOLLOWERS:22 FOLLOWING:14
On my blog: Real Life in Star Trek, Gambit part 1 https://john.colagioia.net/blog/2025/06/19/gambit-part-1.html #scifi #startrek #closereading
Go should be more opinionated
1 points posted by Elton Minetto ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:1376 ARCHIVED:87698 CACHE:2671 FOLLOWERS:22 FOLLOWING:14
@prologic@twtxt.net I’m trying to call some libc functions (because the Rust stdlib does not have an equivalent for getpeername(), for example, so I don’t have a choice), so I have to do some FFI stuff and deal with raw pointers and all that, which is very gnarly in Rust – because you’re not supposed to do this. Things like that are trivial in C or even Assembler, but I have not yet understood what Rust does under the hood. How and when does it allocate or free memory … is the pointer that I get even still valid by the time I do the libc call? Stuff like that.
I hope that I eventually learn this over time … but I get slapped in the face at every step. It’s very frustrating and I’m always this 🤏 close to giving up (only to try again a year later).
Oh, yeah, yeah, I guess I could “just” use some 3rd party library for this. socket2 gets mentioned a lot in this context. But I don’t want to. I literally need one getpeername() call during the lifetime of my program, I don’t even do the socket(), bind(), listen(), accept() dance, I already have a fully functional file descriptor. Using a library for that is total overkill and I’d rather do it myself. (And look at the version number: 0.5.10. The library is 6 years old but they’re still saying: “Nah, we’re not 1.0 yet, we reserve the right to make breaking changes with every new release.” So many Rust libs are still unstable …)
… and I could go on and on and on … 🤣
golang 每日一庫之 barcode
boombuler/barcode 是一個用 Go 編寫的高質量條形碼生成庫,支持多種類型的條形碼和二維碼,使用簡單、擴展性強,非常適合用於生成圖像格式的條碼、二維碼等。倉庫信息—-GitHub: https://github.com/boombuler/barcode Stars: ★ 1.6k+ 許可證: MIT 安裝方式: go get githu ⌘ Read more
Go 語言反射揭祕:獲取 Tag 易如反掌,爲何 json 包卻視而不見?
從詭異現象說起:JSON 爲何忽略私有字段?type User struct{ ID intjson:“id”// 正常導出 Name stringjson:“name”// 正常導出 email stringjson:“email”// 私有字段,JSON無視!}funcmain(){ u := User{1,“Tom”,“tom@example.com”} ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:1375 ARCHIVED:87691 CACHE:2671 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1374 ARCHIVED:87681 CACHE:2671 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1373 ARCHIVED:87677 CACHE:2676 FOLLOWERS:22 FOLLOWING:14
orb v0.1.0 - tiny metasearch | https://nilfm.cc/orb.html
So I was using this function in Rust:
https://doc.rust-lang.org/std/path/struct.Path.html#method.display
Note the little 1.0.0 in the top right corner, which means that this function has been “stable since Rust version 1.0.0”. We’re at 1.87 now, so we’re good.
Then I compiled my program on OpenBSD with Rust 1.86, i.e. just one version behind, but well ahead of 1.0.0.
The compiler said that I was using an unstable library feature.
Turns out, that function internally uses this:
https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.display
And that is only available since Rust 1.87.
How was I supposed to know this? 🤨
🧮 USERS:1 FEEDS:2 TWTS:1372 ARCHIVED:87663 CACHE:2673 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1371 ARCHIVED:87645 CACHE:2661 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1370 ARCHIVED:87623 CACHE:2689 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1369 ARCHIVED:87615 CACHE:2689 FOLLOWERS:22 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:1368 ARCHIVED:87599 CACHE:2702 FOLLOWERS:22 FOLLOWING:14
New oil and gas fields incompatible with Paris climate goals
Opening any new North Sea oil and gas fields is incompatible with achieving the Paris Climate Agreement goals of limiting warming to 1.5°C or holding warming to “well below 2°C” relative to preindustrial levels, finds a new report published by UCL academics. ⌘ Read more
GraphQL Gatecrash: When an Introspection Query Opened the Whole Backend ️
Free Link 🎈
[Continue reading on InfoSec Write-ups »](https://infosecwriteups.com/graphql-gatecrash-when-an-intro … ⌘ Read more
Practical study material OSWP Part 1: WPA2-PSK Walkthrough ⌘ Read more
Could XSS Be the Hidden Key to Account Takeover
What if I told you that a simple Cross-Site Scripting (XSS) vulnerability could be the golden ticket to a full Account Takeover (ATO)? No…
[Continue reading on InfoSec Write-ups »](https://infosecwriteups … ⌘ Read more
Crafting Standalone Python Proof of Concept Exploits
Creating standalone proof of concept exploits implementing a zero-to-hero method, requiring a single action to run.
[Continue reading on InfoSec Write-ups »](https://infosecwriteups.com/craf … ⌘ Read more
$560 Bounty: How Twitter’s Android App Leaked User Location
A Silent Broadcast That Let Any App Spy on You Without Asking
[Continue reading on InfoSec Write-ups »](https://infosecwriteups.com/560-bounty-how-twitters-android-app-leaked- … ⌘ Read more
Radxa UFS/eMMC Module Reader and Storage Solution Enables Fast Flashing and Scalable Embedded Storage
Radxa’s UFS/eMMC Module Reader is a compact USB 3.0 adapter for flashing OS images, accessing firmware, and transferring large files. It supports both eMMC v5.0 and UFS 2.1 modules with speeds up to 5 Gbps The adapter is compatible with eMMC and UFS modules from Radxa, and also works with modules from platforms like PINE64 and […] ⌘ Read more
使用 Zig 開發 Nodejs 原生模塊
Node-API[1](前身爲 N-API)是 Nodejs 提供的用於構建原生插件的 API。它獨立於底層 JavaScript 運行時(例如 V8),並作爲 Node.js 自身的一部分進行維護。該 API 在不同版本的 Node.js 中具有穩定的應用二進制接口 (ABI)。其目的是使附加組件不受底層 JavaScript 引擎變化的影響,並允許爲一個主要版本編譯的模塊在以後的主要 Node ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:1367 ARCHIVED:87591 CACHE:2698 FOLLOWERS:22 FOLLOWING:14
GitOps in 2025: From Old-School Updates to the Modern Way
1. Introduction: Why Everyone’s Talking About GitOps in 2025 It’s 2025, and building software is more cloud-driven than ever. Cloud computing offers incredible speed and flexibility, but it also brings complexity. Companies are expected to ship… ⌘ Read more
Radeon Software For Linux Dropping AMD’s Proprietary OpenGL/Vulkan Drivers
Direct link to upstream release notes.
50 Command Line Tools You Wish You Knew Sooner
Master the terminal with these essential commands that will transform your Linux experience from novice to power user.
[Continue reading on InfoSec Write-ups »](https://infosecwriteups.com/50-command-line-tools-you-wis … ⌘ Read more
Nintendo Switch 2 Hacked in 48 Hours — But Here’s Why It’s Just the Beginning
A harmless green line on the screen may have just opened the floodgates for hackers — inside the first real exploit on Nintendo’ … ⌘ Read more
When you play the Game of RBAC, You either validate, or the world denies your existence — like a King behind the wall.
OIDC: The Digitally signed Pinky Swear “It’s Me” (Part I)
Whenever an Elbow-Shake Protocol is being established, there’s always Users try to communicate safely during Corona pandemic!
[Continue reading on InfoSec Write-ups »](https://infosecwrit … ⌘ Read more
WebSocket Wizardry: How a Forgotten Channel Let Me Sniff Private Chats in Real-Time ️♂️
Hey there!😁
[Continue reading on InfoSec Write-ups »]( … ⌘ Read more