编程语言:Go
通过 Goyacc 构建 Elasticsearch Querystring 解析器 - 领域特定语言语法分析实践
领域特定语言(DSL),如 SQL、Elasticsearch Querystring 等,往往是为专门的目的设计的。在特定的任务中,DSL 通过在表达能力上做的妥协换取在某一领域内的高效。
在飞书套件日志系统的私有化研发过程中,为了符合研发同学查询日志的习惯,尝试使用 Elasticquery Querystring(下简称为 Querystring)作为过滤器的查询条件语句,由此需要可用的 Golang Querystring 解析器。由于目前开源界无法找到完善的实现,尝试使用 Goyacc 自行构建。
Data Race Patterns in Go
Uber has adopted Golang (Go for short) as a primary programming language for developing microservices. Our Go monorepo consists of about 50 million lines of code (and growing) and contains approximately 2,100 unique Go services (and growing).
Go makes concurrency a first-class citizen; prefixing function calls with the go keyword runs the call asynchronously. These asynchronous function calls in Go are called goroutines. Developers hide latency (e.g., IO or RPC calls to other services) by creating goroutines. Two or more goroutines can communicate data either via message passing (channels) or shared memory. Shared memory happens to be the most commonly used means of data communication in Go.
Golang 常见设计模式之单例模式
之前我们已经看过了 Golang 常见设计模式中的装饰和选项模式,今天要看的是 Golang 设计模式里最简单的单例模式。单例模式的作用是确保无论对象被实例化多少次,全局都只有一个实例存在。根据这一特性,我们可以将其应用到全局唯一性配置、数据库连接对象、文件访问对象等。Go 语言实现单例模式的方法有很多种,下面我们就一起来看一下。
Go语言项目实践及新特性解读
近几年之家基于Go在不同的业务场景下(高并发服务、云原生、中间件、机器学习、用户产品、嵌入式等)有着丰富的开发实践,接下来会基于这些场景分享一些典型案例。
Dynamic Data Race Detection in Go Code
Uber has extensively adopted Go as a primary programming language for developing microservices. Our Go monorepo consists of about 50 million lines of code and contains approximately 2,100 unique Go services. Go makes concurrency a first-class citizen; prefixing function calls with the go keyword runs the call asynchronously. These asynchronous function calls in Go are called goroutines. Developers hide latency (e.g., IO or RPC calls to other services) by creating goroutines within a single running Go program. Goroutines are considered “lightweight”, and the Go runtime context switches them on the operating-system (OS) threads. Go programmers often use goroutines liberally. Two or more goroutines can communicate data either via message passing (channels) or shared memory. Shared memory happens to be the most commonly used means of data communication in Go.
A data race occurs in Go when two or more goroutines access the same memory location, at least one of them is a write, and there is no ordering between them, as defined by the Go memory model. Outages caused by data races in Go programs are a recurring and painful problem in our microservices. These issues have brought down our critical, customer-facing services for hours in total, causing inconvenience to our customers and impacting our revenue. In this blog, we discuss deploying Go’s default dynamic race detector to continuously detect data races in our Go development environment. This deployment has enabled detection of more than 2,000 races resulting in ~1,000 data races fixed by more than two hundred engineers.
打造 Go 语言最快的排序算法
说到排序算法,很多同学会想起快速排序、堆排序、冒泡排序这些耳熟能详的算法。了解得深一些的同学,也可能看过例如 Python 的 timsort 以及 C++ intro sort 之类的排序算法。
但是我们也会有很多疑问,例如 Go 语言中使用的快速排序和我们书上学到的快速排序有什么区别呢?如果我们自己写一个快排,会比 Go 语言自带的快吗?排序算法方面业界最新的进展是什么呢,有没有一个算法是最快的?
Golang在商业化广告的优化实践
ssp和adx系统是广告系统中qps最高,io密集度最高的系统,承担着广告大部分收入的同时,对latency不能响应太慢。通过pprof性能调优工具分析系统资源消耗,进行优化实践,性能得到大幅提高,顺利渡过双十一、双十二等大促活动。
百度程序员开发避坑指南(Go语言篇)
日常工作开发中,遇到哪些坑是让你印象深刻且具有挑战的,它们是怎么产生的,我们该如何避免?
Go应用单元测试实践
本文旨在搭建一个稳定运行且维护成本低的单元测试/集成测试环境。
从真实事故出发:golang 内存问题排查指北
在日常的生产环境中,内存出现问题引起的事故通常较为严重,且排查难度较高。本文从一次日常生产中遇到的事故出发,记录了详细(痛苦)的排查过程,最终给大家总结了内存问题的常见场景,以及排查思路,希望可以帮助大家提高一些内存问题的排查解决效率。
东鸽用 Go 语言写了一个能够自动解析新闻网页的算法
输入网页文本(不需要输入 xpath),自动结构化输出标题、发布时间、正文、作者、来源等信息。
Adding the V8 CPU Profiler to v8go
V8 is Google’s open source high-performance JavaScript and WebAssembly engine written in C++. v8go is a library written in Go and C++ allowing users to execute JavaScript from Go using V8 isolates. Using Cgo bindings allows us to run JavaScript in Go at native performance.
The v8go library, developed by Roger Chapman, aims to provide an idiomatic way for Go developers to interface with V8. As it turns out, this can be tricky. For the past few months, I’ve been contributing to v8go to expose functionality in V8. In particular, I’ve been adding support to expose the V8 CPU Profiler.
贝壳Go实现的多云对接存储网关建设
本文主要介绍了贝壳存储网关的使用场景、架构设计以及稳定性建设。
Dubbo-go 优雅上下线设计与实践
优雅上下线可以分为三个角度。服务端的上线,服务端的下线,和客户端的容灾策略。
关于Go并发编程,你不得不知的“左膀右臂”——并发与通道!
并发编程,可以说一直都是开发者们关注最多的主题之一。而Golang作为一个出道就自带“高并发”光环的编程语言,其并发编程的实现原理肯定是值得我们深入探究的。本文主要介绍Goroutine和channel的实现。
一次 Go 使用嵌入式 Rust 库的踩坑实践
故事发生在一个内部项目上,这个项目有 Go 和 Rust 两个部分,其中 Rust 库作为一个存储组件被 Go 的业务部分依赖着。出于种种原因,两个部分需要作为同一个进程来运行,中间有一层 C FFI 接口作为理想与现实的桥梁。
Rust 部分首先将使用到的 Library 的接口和结构使用另一个小小的 cdylib [1] shim 项目封装一下,并通过这个项目生成 Rust 库的编译产物一个动态链接对象和 C 的接口定义。再基于 C 的定义写一个 Go 的 SDK 给上层使用。单独的左边 Go 或者右边 Rust 项目都不够刺激,本文主要集中在中间那一团麻花的部分上,也是我 too young too simple 掉了很多头发的地方。