主页 | Web版 | 订阅 | 归档 | Feed

GopherDaily

20250308

每日一谚:Don not Return -1 or nil to Indicate Error


Go技术生态

关于系统编程语言错误模型的史诗级论文
这篇长达 15000 多字的文章探讨了现有编程语言中错误的表示、传播和处理,并对未来的系统提出了思考。目标读者是那些对编程语言设计感兴趣并熟悉至少几种不同语言中错误表示的从业者(例如错误代码、检查/未检查异常、标记联合、多态变体等)。文章从产品、类型系统和语言设计等多个角度探讨了错误模型,并提出了一个假设的编程语言 Everr 及其错误模型,最后将 Everr 与其他语言进行了比较。

Singleflight:降低 Go 应用程序的成本并提高性能
作为软件工程师,我们应该始终考虑如何提高应用程序的性能,同时降低成本。本文介绍如何使用 singleflight 来同时实现这两个目标。singleflight 是一个标准的 Go 库,它可以防止对同一函数的冗余调用,通过对同一资源的并发请求进行分组,并将第一个结果返回给后续的所有请求,从而降低成本并提高性能。文章通过一个产品价格搜索系统的例子,详细阐述了 singleflight 的使用方法,并使用 Vegeta 进行测试,对比了使用和不使用 singleflight 的性能差异,最后总结了 singleflight 的适用场景和注意事项。

归档 dolthub/swiss GitHub 仓库
由于 Golang 生态系统中存在多个引人注目的 swiss 表实现,我们决定归档 `dolthub/swiss` 仓库。Go 1.24 版本自带了 swiss 表作为 Go 映射实现的基础,其性能甚至优于 `dolthub/swiss`,因此我们选择移除 Dolt 中对 `dolthub/swiss` 的依赖并归档该仓库。

云原生技术

为什么基础设施即代码需要默认安全?
基础设施即代码 (IaC) 已成为管理云基础设施的标准,但它带来了重大挑战,尤其是在安全和合规性方面。诸如配置错误、密钥管理、策略执行和审计等问题可能会使工作流程复杂化。在多云环境中,这些挑战会加剧,其中不同的 IaC 语法、分散的工具链以及资源之间的复杂依赖关系会增加开发人员的认知负担。仅在部署阶段解决安全问题通常被证明是不够的,这会增加成本和违规风险,使组织容易受到攻击。根据我的经验,尽早地在软件开发生命周期 (SDLC) 中强制执行治理和安全最佳实践,可以帮助您从第一行代码开始就对基础设施配置和管理采用真正“默认安全”的方法。

消失的CPU:一个Linux内核调试故事
ClickHouse云平台在GCP上出现神秘的CPU峰值问题,经过数月的调试,发现是Linux内核内存管理中的一个更深层次的问题。工程师Sergei Trifonov通过eBPF追踪、perf分析和可重现的测试案例,最终找到了一个令人惊讶的解决方案,但却紧接着又发现了另一个内核错误。文章详细描述了整个调试过程,以及最终的解决方案。

AI 开发工具:如何使用 Dagger 容器化智能体
Docker 的创建者强烈倡导出于稳健性考虑对 AI 智能体进行容器化。本文介绍了具体方法。

案例研究:Meta 的 Strobelight 利用 eBPF 将 CPU 周期和服务器需求减少高达 20% – eBPF
Meta 开发了 Strobelight,一个利用 eBPF 高效收集可观察性数据的性能分析协调器,解决了在不影响性能的情况下为其后端服务提供全面性能分析数据的问题。该方案在 Meta 的基础设施中带来了显著的效率提升,节省了大量容量并带来了运营效益。通过 eBPF,Strobelight 实现了低开销的数据收集,避免了在二进制文件中添加额外的检测,并保持了高效的性能。它还支持 Meta 基础设施中多个内核版本的功能兼容性,并具备动态采样机制,优化了性能分析速率,避免了存储系统过载。最终结果包括:每年节省 15000 台服务器的容量;Meta 主要服务的服务器数量减少 10-20%;更快的调试和性能分析。

有状态与无状态架构快速入门
本文快速介绍了有状态架构和无状态架构的概念、优缺点以及实际应用场景。有状态架构会记住客户端会话信息,而无状态架构则不会。文章还比较了两种架构的优缺点,并提供了现实世界中的例子,例如电子商务购物车、视频流媒体服务、消息应用等(有状态),以及RESTful API、内容分发网络(CDN)、无服务器函数等(无状态)。最后,文章强调了现代应用通常采用混合方法,并提出了设计时需要考虑的关键问题。

AI

我如今如何使用大型语言模型编写代码
Phillip Carter 分享了在软件开发中使用大型语言模型的经验,例如付费使用 Claude、请求小的代码更改等等。文章探讨了大型语言模型的有效性和局限性,并提供了提高代码生成质量的技巧,例如构建持久的上下文、请求小的代码更改而非大的更改,以及重新思考使用库的决定。作者认为,大型语言模型是一种需要掌握技能才能有效使用的工具,并展望了软件工程的未来,即更关注软件的“是什么”和“为什么”,而不是“怎么做”。

流行工具与项目

dagger/dagger
An open-source runtime for composable workflows. Great for AI agents and CI/CD.

cloudwego/eino
The ultimate LLM/AI application development framework in Golang.

grpc-ecosystem/grpc-gateway
gRPC to JSON proxy generator following the gRPC HTTP spec

mark3labs/mcp-go
A Go implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools.

netbirdio/netbird
Connect your devices into a secure WireGuard®-based overlay network with SSO, MFA and granular access controls.

hashicorp/terraform
Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

weaviate/weaviate
Weaviate is an open-source vector database that stores both objects and vectors, allowing for the combination of vector search with structured filtering with the fault tolerance and scalability of a cloud-native database​.

fleetdm/fleet
Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)

tailscale/tailscale
The easiest, most secure way to use WireGuard and 2FA.

usual2970/certimate
开源的SSL证书管理工具,可以帮助你自动申请、部署SSL证书,并在证书即将过期时自动续期。An open-source SSL certificate management tool that helps you automatically apply for and deploy SSL certificates, as well as automatically renew them when they are about to expire.

googleapis/genai-toolbox
Gen AI Toolbox for Databases is an open source server that makes it easier to build Gen AI tools for interacting with databases.

projectdiscovery/subfinder
Fast passive subdomain enumeration tool.

influxdata/telegraf
Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.

moby/moby
The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

uber-go/mock
GoMock is a mocking framework for the Go programming language.

coder/coder
Provision remote development environments via Terraform

gruntwork-io/terragrunt
Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.

danielmiessler/fabric
fabric is an open-source framework for augmenting humans using AI. It provides a modular framework for solving specific problems using a crowdsourced set of AI prompts that can be used anywhere.

evrone/go-clean-template
Clean Architecture template for Golang services

henrygd/beszel
Lightweight server monitoring hub with historical data, docker stats, and alerts.

go-playground/validator
💯Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

aquasecurity/kube-bench
Checks whether Kubernetes is deployed according to security best practices as defined in the CIS Kubernetes Benchmark

ollama/ollama
Get up and running with Llama 3.3, DeepSeek-R1, Phi-4, Gemma 2, and other large language models.

google/pprof
pprof is a tool for visualization and analysis of profiling data

lightningnetwork/lnd
Lightning Network Daemon ⚡️


编辑:Tony Bai

编辑主页:tonybai.com

GopherDaily项目:github.com/bigwhite/gopherdaily

Copyright 2019-2024 GopherDaily