标签 go 中的文章

敏感词过滤服务

在内容管理项目中,我们经常会用到敏感词检查/过滤服务,这里我们使用 Go 编写一个简单的敏感词过滤服务。 主要功能如下: 加载敏感词列表: 从文件或直接在代码中定义。 添加/删除敏感词: 允许动态修改敏感词列表。 文本过滤: 检测文本中是否包含敏感词,并进行替换或直接返回结果。 我们将使用 Trie (前缀树)……

阅读全文

Golang 为什么nil != nil

摘自go官网 Frequently Asked Questions Why is my nil error value not equal to nil? Under the covers, interfaces are implemented as two elements, a type T and a value V. V is a concrete value such as an int, struct or pointer, never an interface itself, and has type T. For instance, if we store the int value 3 in an interface, the resulting interface value has, schematically, (T=int, V=3). The value V is also known as the interface’s dynamic value, since a given interface variable might hold different values V (and corresponding types T) during the execution of the program. An interface value is nil only if the V and T are both unset, (T=nil, V is not set), In particular, a nil interface will always hold a nil type. If we store a……

阅读全文