CodingLife


  • Home

  • Archives

  • Tags

  • Search

Go基础学习 Go的匿名组合机制

Posted on 2018-11-15

Go 中的面向对象实现

Read more »

Redis常用命令

Posted on 2018-11-11

客户端有自动提示功能,这里只列出关键词。

Read more »

Go使用中的一些特殊的语法点

Posted on 2018-11-08

记录 Go 与 C++等语言的差异语法点

Read more »

Go基础学习 fmt.Stringer接口的坑

Posted on 2018-10-29

一个隐含实现导致的问题:

由于Go的interface的实现是隐含的,只要函数一致就会自动匹配。
先看一下代码: ``` package main

Read more »

Go单元测试方法

Posted on 2018-10-27

Go 中进行单元测试非常方便,官方提供一套 UT 测试框架。

Read more »

Go基础学习 初步使用的总结

Posted on 2018-10-20

在 Go 语言基础学习过程中,确实如 Google 介绍文章写得那样,Go 践行了一系列改进特性,下面就列举一些发现的特性。

Read more »

Go基础学习 string rune

Posted on 2018-10-14


len(“hello 你好”)的迷惑:
Go中的string是以UTF-8编码,底层实现是byte数组,想要输出字符串长度时,如果包含了非Ascii:

1
2
s := string("hello 你好")
fmt.Println(len(s))	// 输出: 12

因为len计算了所有byte数量,而一个中文占3byte。

Read more »

通过Go操作Redis的方法

Posted on 2018-10-10

redigo可以为Go提供操作Redis的API,其本质和手动在”redis-cli”是一样的,只是提供了一些方便的功能。

Read more »

Go实现基本的swap函数

Posted on 2018-09-23

问题

在C++中stl算法中提供了非常好用的swap函数,而Go中目前还没有。
虽然swap的函数很容易通过^实现,但是也要三行代码。

1
2
3
4
5
6
7
8
// 示例,对字符串进行reverse操作,注意这里对[]rune(string)进行操作
func reverse(s []rune) {
    for l, r := 0, len(s) - 1; l < r; l, r = l + 1, r - 1{
        s[l] ^= s[r]
        s[r] ^= s[l]
        s[l] ^= s[r]
    }
}
Read more »

Redis数据类型和应用场景

Posted on 2018-09-12

Redis 命令参考:http://redisdoc.com

Read more »
1 … 25 26 27 … 31
CodeHunter2006

CodeHunter2006

这里包括一些技术经验总结、生活随想和其他...

304 posts
11 categories
85 tags
RSS
GitHub
© 2025 CodeHunter2006
Powered by Jekyll
Theme - NexT.Muse