#453 Kodi 智能电视平台

2021-01-01

了解一下现在热门的智能电视方案 Kodi。

Android TV、Boxee、火狐操作系统、Frog、谷歌电视、Horizon TV、httvLink,、Inview、Kodi Entertainment Center、MeeGo、Mediaroom,、OpenTV,、Opera TV,、Plex,、Roku,、RDK(Reference Development Kit)、智能电视联盟(英文原文:Smart TV Alliance), ToFu Media Platform,、Ubuntu TV以及雅虎智能电视这些平台均由私立机构进行管理。混合广播宽带电视(HbbTV)由混合广播宽带电视协会(英文原文:Hybrid Broadcast Broadband TV association)、CE-HTML是 面向消费类电子产品的网络(英文缩写:Web4CE)的一部分、开放互联网电视论坛(英文缩写:OIPF,英文全称:Open IPTV Forum)是混合广播宽带电视的一部分,还有Tru2way商业化的软件开发平台。

Kodi

https://kodi.tv/
https://en.wikipedia.org/wiki/Kodi_(software)

官网上的定位是 The ultimate entertainment center, 终极娱乐中心。

2002 Xbox Media Player
2004 Xbox Media Center (XBMC)
2008 XBMC 放弃了对 Xbox 的支持
2014 Kodi (从 v14 开始),因为定位已经改成娱乐中心,不再局限于媒体播放,此外,还有商标方面的问题。

https://en.wikipedia.org/wiki/List_of_software_based_on_Kodi_and_XBMC

  • OpenELEC: Open Embedded Linux Entertainment Center
    2017 年之后就没有更新了,主要开发者早已陆续转入了 LibreELEC 项目
  • LibreELEC
  • CoreELEC

其他的产品

Android TV
Apple TV
Amazon Fire TV: 基于 Android TV
Roku OS
SambaTV
三星Tizen
LG WebOS
Panasonic My Home Screen: 基于 Firefox OS

又看到一个项目:
https://plasma-bigscreen.org/zh-cn/

#452 Golang make

2020-12-28
m := make(map[string]int, 5)

发现 len(m) = 0 之后我觉得有必要重新复习一下 make 函数了。

make 的作用:分配内存,初始化,返回值(不是指针)。
PS:返回值的说明:返回的是这三种引用类型本身(指针),而不是指向这三个引用的指针。
PS:new 就会返回指针。还有,new 不限类型,不初始化。

  1. slice -> len, cap
  2. map -> 预留大约 n 个元素的空间(具体分配空间的规则不清楚)
  3. chan -> buffer size

The built-in function make takes a type T, which must be a slice, map or channel type, optionally followed by a type-specific list of expressions. It returns a value of type T (not *T). The memory is initialized as described in the section on initial values.

Call             Type T     Result

make(T, n)       slice      slice of type T with length n and capacity n
make(T, n, m)    slice      slice of type T with length n and capacity m

make(T)          map        map of type T
make(T, n)       map        map of type T with initial space for approximately n elements

make(T)          channel    unbuffered channel of type T
make(T, n)       channel    buffered channel of type T, buffer size n

Each of the size arguments n and m must be of integer type or an untyped constant. A constant size argument must be non-negative and representable by a value of type int; if it is an untyped constant it is given type int. If both n and m are provided and are constant, then n must be no larger than m. If n is negative or larger than m at run time, a run-time panic occurs.

s := make([]int, 10, 100)       // slice with len(s) == 10, cap(s) == 100
s := make([]int, 1e3)           // slice with len(s) == cap(s) == 1000
s := make([]int, 1<<63)         // illegal: len(s) is not representable by a value of type int
s := make([]int, 10, 0)         // illegal: len(s) > cap(s)
c := make(chan int, 10)         // channel with a buffer size of 10
m := make(map[string]int, 100)  // map with initial space for approximately 100 elements

Calling make with a map type and size hint n will create a map with initial space to hold n map elements. The precise behavior is implementation-dependent.

#451 Nginx 版本

2020-12-26

Nginx Release History

参考: https://nginx.org/en/CHANGES-1.20

Version Date
1.20.2 16 Nov 2021
1.20.1 25 May 2021
1.20.0 20 Apr 2021
1.19.10 13 Apr 2021
1.19.9 30 Mar 2021
1.19.8 09 Mar 2021
1.19.7 16 Feb 2021
1.19.6 15 Dec 2020
1.19.5 24 Nov 2020
1.19.4 27 Oct 2020
1.19.3 29 Sep 2020
1.19.2 11 Aug 2020
1.19.1 07 Jul 2020
1.19.0 26 May 2020
1.17.10 14 Apr 2020
1.17.9 03 Mar 2020
1.17.8 21 Jan 2020
1.17.7 24 Dec 2019
1.17.6 19 Nov 2019
1.17.5 22 Oct 2019
1.17.4 24 Sep 2019
1.17.3 13 Aug 2019
1.17.2 23 Jul 2019
1.17.1 25 Jun 2019
1.17.0 21 May 2019
1.15.12 16 Apr 2019
1.15.11 09 Apr 2019
1.15.10 26 Mar 2019
1.15.9 26 Feb 2019
1.15.8 25 Dec 2018
1.15.7 27 Nov 2018
1.15.6 06 Nov 2018
1.15.5 02 Oct 2018
1.15.4 25 Sep 2018
1.15.3 28 Aug 2018
1.15.2 24 Jul 2018
1.15.1 03 Jul 2018
1.15.0 05 Jun 2018
1.13.12 10 Apr 2018
1.13.11 03 Apr 2018
1.13.10 20 Mar 2018
1.13.9 20 Feb 2018
1.13.8 26 Dec 2017
1.13.7 21 Nov 2017
1.13.6 10 Oct 2017
1.13.5 05 Sep 2017
1.13.4 08 Aug 2017
1.13.3 11 Jul 2017
1.13.2 27 Jun 2017
1.13.1 30 May 2017
1.13.0 25 Apr 2017
1.11.13 04 Apr 2017
1.11.12 24 Mar 2017
1.11.11 21 Mar 2017
1.11.10 14 Feb 2017
1.11.9 24 Jan 2017
1.11.8 27 Dec 2016
1.11.7 13 Dec 2016
1.11.6 15 Nov 2016
1.11.5 11 Oct 2016
1.11.4 13 Sep 2016
1.11.3 26 Jul 2016
1.11.2 05 Jul 2016
1.11.1 31 May 2016
1.11.0 24 May 2016
1.9.15 19 Apr 2016
1.9.14 05 Apr 2016
1.9.13 29 Mar 2016
1.9.12 24 Feb 2016
1.9.11 09 Feb 2016
1.9.10 26 Jan 2016
1.9.9 09 Dec 2015
1.9.8 08 Dec 2015
1.9.7 17 Nov 2015
1.9.6 27 Oct 2015
1.9.5 22 Sep 2015
1.9.4 18 Aug 2015
1.9.3 14 Jul 2015
1.9.2 16 Jun 2015
1.9.1 26 May 2015
1.9.0 28 Apr 2015
1.7.12 07 Apr 2015
1.7.11 24 Mar 2015
1.7.10 10 Feb 2015
1.7.9 23 Dec 2014
1.7.8 02 Dec 2014
1.7.7 28 Oct 2014
1.7.6 30 Sep 2014
1.7.5 16 Sep 2014
1.7.4 05 Aug 2014
1.7.3 08 Jul 2014
1.7.2 17 Jun 2014
1.7.1 27 May 2014
1.7.0 24 Apr 2014
1.5.13 08 Apr 2014
1.5.12 18 Mar 2014
1.5.11 04 Mar 2014
1.5.10 04 Feb 2014
1.5.9 22 Jan 2014
1.5.8 17 Dec 2013
1.5.7 19 Nov 2013
1.5.6 01 Oct 2013
1.5.5 17 Sep 2013
1.5.4 27 Aug 2013
1.5.3 30 Jul 2013
1.5.2 02 Jul 2013
1.5.1 04 Jun 2013
1.5.0 07 May 2013
1.4.0 24 Apr 2013
1.3.16 16 Apr 2013
1.3.15 26 Mar 2013
1.3.14 05 Mar 2013
1.3.13 19 Feb 2013
1.3.12 05 Feb 2013
1.3.11 10 Jan 2013
1.3.10 25 Dec 2012
1.3.9 27 Nov 2012
1.3.8 30 Oct 2012
1.3.7 02 Oct 2012
1.3.6 12 Sep 2012
1.3.5 21 Aug 2012
1.3.4 31 Jul 2012
1.3.3 10 Jul 2012
1.3.2 26 Jun 2012
1.3.1 05 Jun 2012
1.3.0 15 May 2012
1.2.0 23 Apr 2012
1.1.19 12 Apr 2012
1.1.18 28 Mar 2012
1.1.17 15 Mar 2012
1.1.16 29 Feb 2012
1.1.15 15 Feb 2012
1.1.14 30 Jan 2012
1.1.13 16 Jan 2012
1.1.12 26 Dec 2011
1.1.11 12 Dec 2011
1.1.10 30 Nov 2011
1.1.9 28 Nov 2011
1.1.8 14 Nov 2011
1.1.7 31 Oct 2011
1.1.6 17 Oct 2011
1.1.5 05 Oct 2011
1.1.4 20 Sep 2011
1.1.3 14 Sep 2011
1.1.2 05 Sep 2011
1.1.1 22 Aug 2011
1.1.0 01 Aug 2011
1.0.5 19 Jul 2011
1.0.4 01 Jun 2011
1.0.3 25 May 2011
1.0.2 10 May 2011
1.0.1 03 May 2011
1.0.0 12 Apr 2011
0.9.7 04 Apr 2011
0.9.6 21 Mar 2011
0.9.5 21 Feb 2011
0.9.4 21 Jan 2011
0.9.3 13 Dec 2010
0.9.2 06 Dec 2010
0.9.1 30 Nov 2010
0.9.0 29 Nov 2010
0.8.53 18 Oct 2010
0.8.52 28 Sep 2010
0.8.51 27 Sep 2010
0.8.50 02 Sep 2010
0.8.49 09 Aug 2010
0.8.48 03 Aug 2010
0.8.47 28 Jul 2010
0.8.46 19 Jul 2010
0.8.45 13 Jul 2010
0.8.44 05 Jul 2010
0.8.43 30 Jun 2010
0.8.42 21 Jun 2010
0.8.41 15 Jun 2010
0.8.40 07 Jun 2010
0.8.39 31 May 2010
0.8.38 24 May 2010
0.8.37 17 May 2010
0.8.36 22 Apr 2010
0.8.35 01 Apr 2010
0.8.34 03 Mar 2010
0.8.33 01 Feb 2010
0.8.32 11 Jan 2010
0.8.31 23 Dec 2009
0.8.30 15 Dec 2009
0.8.29 30 Nov 2009
0.8.28 23 Nov 2009
0.8.27 17 Nov 2009
0.8.26 16 Nov 2009
0.8.25 16 Nov 2009
0.8.24 11 Nov 2009
0.8.23 11 Nov 2009
0.8.22 03 Nov 2009
0.8.21 26 Oct 2009
0.8.20 14 Oct 2009
0.8.19 06 Oct 2009
0.8.18 06 Oct 2009
0.8.17 28 Sep 2009
0.8.16 22 Sep 2009
0.8.15 14 Sep 2009
0.8.14 07 Sep 2009
0.8.13 31 Aug 2009
0.8.12 31 Aug 2009
0.8.11 28 Aug 2009
0.8.10 24 Aug 2009
0.8.9 17 Aug 2009
0.8.8 10 Aug 2009
0.8.7 27 Jul 2009
0.8.6 20 Jul 2009
0.8.5 13 Jul 2009
0.8.4 22 Jun 2009
0.8.3 19 Jun 2009
0.8.2 15 Jun 2009
0.8.1 08 Jun 2009
0.8.0 02 Jun 2009
0.7.59 25 May 2009
0.7.58 18 May 2009
0.7.57 12 May 2009
0.7.56 11 May 2009
0.7.55 06 May 2009
0.7.54 01 May 2009
0.7.53 27 Apr 2009
0.7.52 20 Apr 2009
0.7.51 12 Apr 2009
0.7.50 06 Apr 2009
0.7.49 06 Apr 2009
0.7.48 06 Apr 2009
0.7.47 01 Apr 2009
0.7.46 30 Mar 2009
0.7.45 30 Mar 2009
0.7.44 23 Mar 2009
0.7.43 18 Mar 2009
0.7.42 16 Mar 2009
0.7.41 11 Mar 2009
0.7.40 09 Mar 2009
0.7.39 02 Mar 2009
0.7.38 23 Feb 2009
0.7.37 21 Feb 2009
0.7.36 21 Feb 2009
0.7.35 16 Feb 2009
0.7.34 10 Feb 2009
0.7.33 02 Feb 2009
0.7.32 26 Jan 2009
0.7.31 19 Jan 2009
0.7.30 24 Dec 2008
0.7.29 24 Dec 2008
0.7.28 22 Dec 2008
0.7.27 15 Dec 2008
0.7.26 08 Dec 2008
0.7.25 08 Dec 2008
0.7.24 01 Dec 2008
0.7.23 27 Nov 2008
0.7.22 20 Nov 2008
0.7.21 11 Nov 2008
0.7.20 10 Nov 2008
0.7.19 13 Oct 2008
0.7.18 13 Oct 2008
0.7.17 15 Sep 2008
0.7.16 08 Sep 2008
0.7.15 08 Sep 2008
0.7.14 01 Sep 2008
0.7.13 26 Aug 2008
0.7.12 26 Aug 2008
0.7.11 18 Aug 2008
0.7.10 13 Aug 2008
0.7.9 12 Aug 2008
0.7.8 04 Aug 2008
0.7.7 30 Jul 2008
0.7.6 07 Jul 2008
0.7.5 01 Jul 2008
0.7.4 30 Jun 2008
0.7.3 23 Jun 2008
0.7.2 16 Jun 2008
0.7.1 26 May 2008
0.7.0 19 May 2008
0.6.31 12 May 2008
0.6.30 29 Apr 2008
0.6.29 18 Mar 2008
0.6.28 13 Mar 2008
0.6.27 12 Mar 2008
0.6.26 11 Feb 2008
0.6.25 08 Jan 2008
0.6.24 27 Dec 2007
0.6.23 27 Dec 2007
0.6.22 19 Dec 2007
0.6.21 03 Dec 2007
0.6.20 28 Nov 2007
0.6.19 27 Nov 2007
0.6.18 27 Nov 2007
0.6.17 15 Nov 2007
0.6.16 29 Oct 2007
0.6.15 22 Oct 2007
0.6.14 15 Oct 2007
0.6.13 24 Sep 2007
0.6.12 21 Sep 2007
0.6.11 11 Sep 2007
0.6.10 03 Sep 2007
0.6.9 28 Aug 2007
0.6.8 20 Aug 2007
0.6.7 15 Aug 2007
0.6.6 30 Jul 2007
0.6.5 23 Jul 2007
0.6.4 17 Jul 2007
0.6.3 12 Jul 2007
0.6.2 09 Jul 2007
0.6.1 17 Jun 2007
0.6.0 14 Jun 2007
0.5.25 11 Jun 2007
0.5.24 06 Jun 2007
0.5.23 04 Jun 2007
0.5.22 29 May 2007
0.5.21 28 May 2007
0.5.20 07 May 2007
0.5.19 24 Apr 2007
0.5.18 19 Apr 2007
0.5.17 02 Apr 2007
0.5.16 26 Mar 2007
0.5.15 19 Mar 2007
0.5.14 23 Feb 2007
0.5.13 19 Feb 2007
0.5.12 12 Feb 2007
0.5.11 05 Feb 2007
0.5.10 26 Jan 2007
0.5.9 25 Jan 2007
0.5.8 19 Jan 2007
0.5.7 15 Jan 2007
0.5.6 09 Jan 2007
0.5.5 24 Dec 2006
0.5.4 15 Dec 2006
0.5.3 13 Dec 2006
0.5.2 11 Dec 2006
0.5.1 11 Dec 2006
0.5.0 04 Dec 2006
0.4.14 27 Nov 2006
0.4.13 15 Nov 2006
0.4.12 31 Oct 2006
0.4.11 25 Oct 2006
0.4.10 23 Oct 2006
0.4.9 13 Oct 2006
0.4.8 11 Oct 2006
0.4.7 10 Oct 2006
0.4.6 06 Oct 2006
0.4.5 02 Oct 2006
0.4.4 02 Oct 2006
0.4.3 26 Sep 2006
0.4.2 14 Sep 2006
0.4.1 14 Sep 2006
0.4.0 30 Aug 2006
0.3.61 28 Aug 2006
0.3.60 18 Aug 2006
0.3.59 16 Aug 2006
0.3.58 14 Aug 2006
0.3.57 09 Aug 2006
0.3.56 04 Aug 2006
0.3.55 28 Jul 2006
0.3.54 11 Jul 2006
0.3.53 07 Jul 2006
0.3.52 03 Jul 2006
0.3.51 30 Jun 2006
0.3.50 28 Jun 2006
0.3.49 31 May 2006
0.3.48 29 May 2006
0.3.47 23 May 2006
0.3.46 11 May 2006
0.3.45 06 May 2006
0.3.44 04 May 2006
0.3.43 26 Apr 2006
0.3.42 26 Apr 2006
0.3.41 21 Apr 2006
0.3.40 19 Apr 2006
0.3.39 17 Apr 2006
0.3.38 14 Apr 2006
0.3.37 07 Apr 2006
0.3.36 05 Apr 2006
0.3.35 22 Mar 2006
0.3.34 21 Mar 2006
0.3.33 15 Mar 2006
0.3.32 11 Mar 2006
0.3.31 10 Mar 2006
0.3.30 22 Feb 2006
0.3.29 20 Feb 2006
0.3.28 16 Feb 2006
0.3.27 08 Feb 2006
0.3.26 03 Feb 2006
0.3.25 01 Feb 2006
0.3.24 01 Feb 2006
0.3.23 24 Jan 2006
0.3.22 17 Jan 2006
0.3.21 16 Jan 2006
0.3.20 11 Jan 2006
0.3.19 28 Dec 2005
0.3.18 26 Dec 2005
0.3.17 18 Dec 2005
0.3.16 16 Dec 2005
0.3.15 07 Dec 2005
0.3.14 05 Dec 2005
0.3.13 05 Dec 2005
0.3.12 26 Nov 2005
0.3.11 15 Nov 2005
0.3.10 15 Nov 2005
0.3.9 10 Nov 2005
0.3.8 09 Nov 2005
0.3.7 27 Oct 2005
0.3.6 24 Oct 2005
0.3.5 21 Oct 2005
0.3.4 19 Oct 2005
0.3.3 19 Oct 2005
0.3.2 12 Oct 2005
0.3.1 10 Oct 2005
0.3.0 07 Oct 2005
0.2.6 05 Oct 2005
0.2.5 04 Oct 2005
0.2.4 03 Oct 2005
0.2.3 30 Sep 2005
0.2.2 30 Sep 2005
0.2.1 23 Sep 2005
0.2.0 23 Sep 2005
0.1.45 08 Sep 2005
0.1.44 06 Sep 2005
0.1.43 30 Aug 2005
0.1.42 23 Aug 2005
0.1.41 25 Jul 2005
0.1.40 22 Jul 2005
0.1.39 14 Jul 2005
0.1.38 08 Jul 2005
0.1.37 23 Jun 2005
0.1.36 15 Jun 2005
0.1.35 07 Jun 2005
0.1.34 26 May 2005
0.1.33 23 May 2005
0.1.32 19 May 2005
0.1.31 16 May 2005
0.1.30 14 May 2005
0.1.29 12 May 2005
0.1.28 08 Apr 2005
0.1.27 28 Mar 2005
0.1.26 22 Mar 2005
0.1.25 19 Mar 2005
0.1.24 04 Mar 2005
0.1.23 01 Mar 2005
0.1.22 22 Feb 2005
0.1.21 22 Feb 2005
0.1.20 17 Feb 2005
0.1.19 16 Feb 2005
0.1.18 09 Feb 2005
0.1.17 03 Feb 2005
0.1.16 25 Jan 2005
0.1.15 19 Jan 2005
0.1.14 18 Jan 2005
0.1.13 21 Dec 2004
0.1.12 06 Dec 2004
0.1.11 02 Dec 2004
0.1.10 26 Nov 2004
0.1.9 25 Nov 2004
0.1.8 20 Nov 2004
0.1.7 12 Nov 2004
0.1.6 11 Nov 2004
0.1.5 11 Nov 2004
0.1.4 26 Oct 2004
0.1.3 25 Oct 2004
0.1.2 21 Oct 2004
0.1.1 11 Oct 2004
0.1.0 04 Oct 2004

#450 Golang: 命令行参数解析(flag

2020-12-25

Go 自带 flag 包,可以用于解析命令行参数。但用起来非常繁琐,更谈不上优雅,远不如 Python 的 argparse 包简洁明了,易于使用。

语法

类型

  • flag.Flag
  • flag.FlagSet
  • flag.Getter
  • flag.Value

方法

func Bool(name string, value bool, usage string) *bool
func BoolVar(p *bool, name string, value bool, usage string)

func Duration(name string, value time.Duration, usage string) *time.Duration
func DurationVar(p *time.Duration, name string, value time.Duration, usage string)

func Float64(name string, value float64, usage string) *float64
func Float64Var(p *float64, name string, value float64, usage string)

func Func(name, usage string, fn func(string) error)

func Int(name string, value int, usage string) *int
func IntVar(p *int, name string, value int, usage string)

func Int64(name string, value int64, usage string) *int64
func Int64Var(p *int64, name string, value int64, usage string)

func String(name string, value string, usage string) *string
func StringVar(p *string, name string, value string, usage string)

func Uint(name string, value uint, usage string) *uint
func UintVar(p *uint, name string, value uint, usage string)

func Uint64(name string, value uint64, usage string) *uint64
func Uint64Var(p *uint64, name string, value uint64, usage string)

func Var(value Value, name string, usage string)
  1. 带 Var 结尾的方法表示将值绑定到一个变量上。
func Arg(i int) string  // i-th argument
func Args() []string    // non-flag arguments

func NArg() int         // number of arguments remaining after flags have been processed
func NFlag() int        // number of command-line flags that have been set

func Parse()
func Parsed() bool
func Set(name, value string) error

func PrintDefaults()    // 帮助信息
func UnquoteUsage(flag *Flag) (name string, usage string)  // 返回 flag 的名称和用法

func Visit(fn func(*Flag))
func VisitAll(fn func(*Flag))

type ErrorHandling

FlagSet

func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet

上面的方法 FlagSet 也都有一份。

示例:Todo

package main

import (
    "flag"
    "fmt"
)

var (
    addFlag       = flag.String("add", "", "Add a new task")
    listFlag      = flag.Bool("list", false, "List all tasks")
    removeFlag    = flag.Int("remove", -1, "Remove a task by its index")
    removeAllFlag = flag.Bool("remove-all", false, "Remove all tasks")
    doneFlag      = flag.Int("done", -1, "Mark a task as done by its index")
    undoneFlag    = flag.Int("undone", -1, "Mark a task as undone by its index")
)

func main() {
    flag.Parse()
    args := make(map[string]interface{}, 10)
    args["add"] = *addFlag
    args["list"] = *listFlag
    args["remove"] = *removeFlag
    args["remove"] = *removeAllFlag
    args["done"] = *doneFlag
    args["undone"] = *undoneFlag
    fmt.Printf("%#v\n", args)
    // map[string]interface {}{"add":"", "done":-1, "list":false, "remove":false, "undone":-1}
    fmt.Println("Other arguments:", flag.Args())
    // Other arguments: []
}

参考资料与拓展阅读

#449 韩信:功臣末路断头颅

2020-12-24

听易中天讲韩信(《汉末风云人物》)时说了这句,功臣末路断头颅。我以为是来自古文或古诗,一查,原来来自九十年代一部电视剧的主题曲。
《淮阴侯韩信》

#448 Go 知名项目

2020-12-21

按照 stars 排序,就取头部的一些项目分析一下:

  1. golang/go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The Go programming language
    跳过
  2. kubernetes/kubernetes shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Production-Grade Container Scheduling and Management
    K8S,跳过
  3. avelino/awesome-go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A curated list of awesome Go frameworks, libraries and software
    一个重要的学习参考。
  4. moby/moby shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
    Docker,跳过
  5. gin-gonic/gin shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
    Gin,跳过
  6. gohugoio/hugo shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The world’s fastest framework for building websites.
    Hugo,知名静态网站生成工具
  7. fatedier/frp shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
    frp, 知名网络工具
  8. syncthing/syncthing shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Open Source Continuous File Synchronization
    知名文件同步工具
  9. junegunn/fzf shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    :cherry_blossom: A command-line fuzzy finder
    fzf,知名 find 命令替代品
  10. prometheus/prometheus shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The Prometheus monitoring system and time series database.
    知名监控平台
  11. caddyserver/caddy shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Fast, multi-platform web server with automatic HTTPS
    知名 HTTP 服务器
  12. astaxie/build-web-application-with-golang shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A golang ebook intro how to build a web with golang
    《Go Web 编程》
  13. gogs/gogs shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Gogs is a painless self-hosted Git service
    知名 Git 服务器
  14. etcd-io/etcd shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Distributed reliable key-value store for the most critical data of a distributed system
    知名 KV 存储服务
  15. v2ray/v2ray-core shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A platform for building proxies to bypass network restrictions.
    知名网络工具
  16. traefik/traefik shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The Cloud Native Application Proxy
    知名代理服务
  17. ethereum/go-ethereum shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Official Go implementation of the Ethereum protocol
    知名区块链项目
  18. FiloSottile/mkcert shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A simple zero-config tool to make locally trusted development certificates with any names you'd like.
  19. minio/minio shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Multi-Cloud Object Storage
  20. rclone/rclone shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    "rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Yandex Files
  21. hashicorp/terraform shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
  22. wagoodman/dive shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A tool for exploring each layer in a docker image
  23. evanw/esbuild shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An extremely fast JavaScript and CSS bundler and minifier
    知名前端构建工具
  24. pingcap/tidb shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try free: https://tidbcloud.com/signup
    知名国产数据库
  25. istio/istio shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Connect, secure, control, and observe services.
    知名服务网格组件
  26. go-gitea/gitea shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Git with a cup of tea, painless self-hosted git service
    知名 Git 服务(gogs fork)
  27. unknwon/the-way-to-go_ZH_CN shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    《The Way to Go》中文译本,中文正式名《Go 入门指南》
  28. cli/cli shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    GitHub’s official command line tool
    GitHub 官方命令行工具
  29. go-gorm/gorm shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The fantastic ORM library for Golang, aims to be developer friendly
    知名 Go ORM 库
  30. beego/beego shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    beego is an open-source, high-performance web framework for the Go programming language.
    知名 Go web 框架
  31. jesseduffield/lazygit shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    simple terminal UI for git commands
    Git 终端界面
  32. Dreamacro/clash shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A rule-based tunnel in Go.
    网络工具
  33. spf13/cobra shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A Commander for modern Go CLI interactions
  34. docker/compose shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Define and run multi-container applications with Docker
  35. halfrost/LeetCode-Go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    ✅ Solutions to LeetCode by Go, 100% test coverage, runtime beats 100% / LeetCode 题解
  36. harness/drone shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Drone is a Container-Native, Continuous Delivery Platform
    知名 CI/CD 服务
  37. hashicorp/consul shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
    知名服务发现和配置管理服务
  38. cockroachdb/cockroach shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    CockroachDB - the open source, cloud-native distributed SQL database.
    数据库
  39. nektos/act shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Run your GitHub Actions locally 🚀
    开发工具:GitHub Action
  40. hashicorp/vault shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A tool for secrets management, encryption as a service, and privileged access management
    安全相关服务
  41. kubernetes/minikube shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Run Kubernetes locally
    知名 K8S 项目
  42. influxdata/influxdb shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Scalable datastore for metrics, events, and real-time analytics
    知名时序数据库
  43. go-kit/kit shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A standard library for microservices.
    微服务框架
  44. mattermost/mattermost-server shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Mattermost is an open source platform for secure collaboration across the entire software development lifecycle.
    研发团队协作工具
  45. jesseduffield/lazydocker shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The lazier way to manage everything docker
    Docker 管理工具
  46. labstack/echo shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    High performance, minimalist Go web framework
    知名 HTTP 框架
  47. kataras/iris shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The fastest HTTP/2 Go Web Framework. A true successor of expressjs and laravel. Supports AWS Lambda, gRPC, MVC, Unique Router, Websockets, Sessions, Test suite, Dependency Injection and more. Thank you / 谢谢 https://github.com/kataras/iris/issues/1329
    知名 HTTP 框架
  48. portainer/portainer shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Making Docker and Kubernetes management easy.
    知名容器管理平台
  49. helm/helm shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The Kubernetes Package Manager
    知名 K8S 项目
  50. github/hub shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A command-line tool that makes git easier to use with GitHub.
  51. inconshreveable/ngrok shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Introspected tunnels to localhost
  52. openfaas/faas shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    OpenFaaS - Serverless Functions Made Simple
    知名 FaaS 项目
  53. ehang-io/nps shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    一款轻量级、高性能、功能强大的内网穿透代理服务器。支持 tcp、udp、socks5、http 等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh 访问、远程桌面,内网 dns 解析、内网 socks5 代理等等……,并带有功能强大的 web 管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
  54. nsqio/nsq shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A realtime distributed messaging platform
    知名 MQ 服务
  55. coreybutler/nvm-windows shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A node.js version management utility for Windows. Ironically written in Go.
    开发工具:前端相关
  56. photoprism/photoprism shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    AI-Powered Photos App for the Decentralized Web 🌈💎✨
    照片管理系统
  57. sirupsen/logrus shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Structured, pluggable logging for Go.
    重要的日志库
  58. yeasy/docker_practice shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Learn and understand Docker&Container technologies, with real DevOps practice!
    电子书:Docker 技术入门与实战
  59. gofiber/fiber shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    ⚡️ Express inspired web framework written in Go
    知名 Web 框架
  60. k3s-io/k3s shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Lightweight Kubernetes
    知名 K8S 项目
  61. tsenart/vegeta shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    HTTP load testing tool and library. It's over 9000!
    HTTP 压测工具
  62. schollz/croc shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Easily and securely send things from one computer to another :crocodile: :package:
    工具:文件传输
  63. zyedidia/micro shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A modern and intuitive terminal-based text editor
    工具:编辑器
  64. spf13/viper shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Go configuration with fangs
    配置管理库
  65. rancher/rancher shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Complete container management platform
    知名容器管理平台
  66. tmrts/go-patterns shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Curated list of Go design patterns, recipes and idioms
    设计模式
  67. go-delve/delve shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Delve is a debugger for the Go programming language.
    调试工具
  68. urfave/cli shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A simple, fast, and fun package for building command line apps in Go
    命令行库
  69. asim/go-micro shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A Go microservices framework
    知名 Go 微服务框架
  70. dgraph-io/dgraph shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Native GraphQL Database with graph backend
    GraphQL 数据库(?)
  71. dapr/dapr shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Dapr is a portable, event-driven, runtime for building distributed applications across cloud and edge.
    知名微服务平台
  72. iawia002/lux shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    👾 Fast and simple video download library and CLI tool written in Go
    工具:视频下载
  73. go-kratos/kratos shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Your ultimate Go microservices framework for the cloud-native era.
    微服务框架
  74. zeromicro/go-zero shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A cloud-native Go microservices framework with cli tool for productivity.
    微服务框架
  75. valyala/fasthttp shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
    HTTP 库
  76. quii/learn-go-with-tests shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Learn Go with test-driven development
    资料:TDD
  77. goharbor/harbor shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An open source trusted cloud native registry project that stores, signs, and scans content.
  78. gorilla/websocket shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A fast, well-tested and widely used WebSocket implementation for Go.
  79. chai2010/advanced-go-programming-book shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    :books: 《Go 语言高级编程》开源图书,涵盖 CGO、Go 汇编语言、RPC 实现、Protobuf 插件实现、Web 框架实现、分布式系统等高阶主题(完稿)
  80. restic/restic shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Fast, secure, efficient backup program
  81. fyne-io/fyne shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Cross platform GUI in Go inspired by Material Design
  82. gorilla/mux shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A powerful HTTP router and URL matcher for building Go web servers with 🦍
    知名 HTTP 路由库
  83. gocolly/colly shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Elegant Scraper and Crawler Framework for Golang
    爬虫框架
  84. yudai/gotty shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Share your terminal as a web application
    终端分享
  85. grafana/k6 shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A modern load testing tool, using Go and JavaScript - https://k6.io
    测试工具
  86. stretchr/testify shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A toolkit with common assertions and mocks that plays nicely with the standard library
  87. derailed/k9s shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    🐶 Kubernetes CLI To Manage Your Clusters In Style!
    K8S 相关
  88. joewalnes/websocketd shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.
  89. matryer/xbar shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
  90. grpc/grpc-go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The Go language implementation of gRPC. HTTP/2 based RPC
  91. v2fly/v2ray-core shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A platform for building proxies to bypass network restrictions.
    网络工具
  92. grafana/loki shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Like Prometheus, but for logs.
    日志服务
  93. filebrowser/filebrowser shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    📂 Web File Browser
    Web 项目
  94. uber-go/zap shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Blazing fast, structured, leveled logging in Go.
    知名日志库
  95. jaegertracing/jaeger shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    CNCF Jaeger, a Distributed Tracing Platform
  96. buger/goreplay shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    GoReplay is an open-source tool for capturing and replaying live HTTP traffic into a test environment in order to continuously test your system with real data. It can be used to increase confidence in code deployments, configuration changes and infrastructure changes.
  97. helm/charts shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    ⚠️(OBSOLETE) Curated applications for Kubernetes
  98. hoanhan101/ultimate-go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The Ultimate Go Study Guide
  99. cloudreve/Cloudreve shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    🌩 支持多家云存储的云盘系统 (Self-hosted file management and sharing system, supports multiple storage providers)
  100. chrislusf/seaweedfs shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    SeaweedFS is a fast distributed storage system for blobs, objects, files, and data lake, for billions of files! Blob store has O(1) disk seek, cloud tiering. Filer supports Cloud Drive, cross-DC active-active replication, Kubernetes, POSIX FUSE mount, S3 API, S3 Gateway, Hadoop, WebDAV, encryption, Erasure Coding.
  101. go-redis/redis shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Type-safe Redis client for Golang
  102. antonmedv/fx shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Terminal JSON viewer
  103. cayleygraph/cayley shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An open-source graph database
  104. vitessio/vitess shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Vitess is a database clustering system for horizontal scaling of MySQL.
  105. julienschmidt/httprouter shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A high performance HTTP request router that scales well
  106. kubernetes/kops shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Kubernetes Operations (kOps) - Production Grade k8s Installation, Upgrades and Management
  107. containers/podman shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Podman: A tool for managing OCI containers and pods.
  108. hashicorp/packer shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
  109. docker-slim/docker-slim shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    DockerSlim (docker-slim): Don't change anything in your Docker container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
  110. hyperledger/fabric shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Hyperledger Fabric is an enterprise-grade permissioned distributed ledger framework for developing solutions and applications. Its modular and versatile design satisfies a broad range of industry use cases. It offers a unique approach to consensus that enables performance at scale while preserving privacy.
  111. ipfs/go-ipfs shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    IPFS implementation in Go
  112. rakyll/hey shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    HTTP load generator, ApacheBench (ab) replacement
  113. wtfutil/wtf shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The personal information dashboard for your terminal
  114. greyireland/algorithm-pattern shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    算法模板,最科学的刷题方式,最快速的刷题路径,你值得拥有~
  115. google/cadvisor shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Analyzes resource usage and performance characteristics of running containers.
  116. grpc-ecosystem/grpc-gateway shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    gRPC to JSON proxy generator following the gRPC HTTP spec
  117. inancgumus/learngo shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    1000+ Hand-Crafted Go Examples, Exercises, and Quizzes
  118. authelia/authelia shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The Single Sign-On Multi-Factor portal for web apps
  119. flipped-aurora/gin-vue-admin shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    基于 vite+vue3+gin 搭建的开发基础平台(已完成 setup 语法糖版本),集成 jwt 鉴权,权限管理,动态路由,显隐可控组件,分页封装,多点登录拦截,资源权限,上传下载,代码生成器,表单生成器等开发必备功能。
  120. golang/dep shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Go dependency management tool experiment (deprecated)
  121. ahmetb/kubectx shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Faster way to switch between clusters and namespaces in kubectl
  122. txthinking/brook shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A cross-platform network tool designed for developers. 一个为开发者设计的跨平台网络工具.
  123. xtaci/kcptun shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC. Available for ARM, MIPS, 386 and AMD64。KCP プロトコルに基づく安全なトンネル。KCP 프로토콜을 기반으로 하는 보안 터널입니다。
  124. GoogleContainerTools/skaffold shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Easy and Repeatable Kubernetes Development
  125. bcicen/ctop shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Top-like interface for container metrics
  126. boltdb/bolt shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An embedded key/value database for Go.
  127. kubernetes/ingress-nginx shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    NGINX Ingress Controller for Kubernetes
  128. google/gvisor shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Application Kernel for Containers
  129. dutchcoders/transfer.sh shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Easy and fast file sharing from the command-line.
  130. revel/revel shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A high productivity, full-stack web framework for the Go language.
  131. ory/hydra shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Works with Hardware Security Modules. Compatible with MITREid.
  132. pulumi/pulumi shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Pulumi - Universal Infrastructure as Code. Your Cloud, Your Language, Your Way 🚀
  133. charmbracelet/bubbletea shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A powerful little TUI framework 🏗
  134. CodisLabs/codis shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Proxy based Redis cluster solution supporting pipeline and scaling dynamically
  135. go-sql-driver/mysql shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package
  136. snail007/goproxy shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    🔥 Proxy is a high performance HTTP(S) proxies, SOCKS5 proxies,WEBSOCKET, TCP, UDP proxy server implemented by golang. Now, it supports chain-style proxies,nat forwarding in different lan,TCP/UDP port forwarding, SSH forwarding.Proxy 是 golang 实现的高性能 http,https,websocket,tcp,socks5 代理服务器,支持内网穿透,链式代理,通讯加密,智能 HTTP,SOCKS5 代理,黑白名单,限速,限流量,限连接数,跨平台,KCP 支持,认证 API。
  137. aquasecurity/trivy shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Scanner for vulnerabilities in container images, file systems, and Git repositories, as well as for configuration issues and hard-coded secrets
  138. Netflix/chaosmonkey shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Chaos Monkey is a resiliency tool that helps applications tolerate random instance failures.
  139. cilium/cilium shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    eBPF-based Networking, Security, and Observability
  140. casbin/casbin shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
  141. jmoiron/sqlx shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    general purpose extensions to golang's database/sql
  142. gravitational/teleport shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Certificate authority and access plane for SSH, Kubernetes, web apps, databases and desktops
  143. qax-os/excelize shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
  144. fogleman/primitive shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Reproducing images with geometric primitives.
  145. gizak/termui shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Golang terminal dashboard
  146. peterq/pan-light shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    百度网盘不限速客户端, golang + qt5, 跨平台图形界面
  147. AdguardTeam/AdGuardHome shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Network-wide ads & trackers blocking DNS server
  148. influxdata/telegraf shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The plugin-driven server agent for collecting & reporting metrics.
  149. emirpasic/gods shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    GoDS (Go Data Structures) - Sets, Lists, Stacks, Maps, Trees, Queues, and much more
  150. PuerkitoBio/goquery shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A little like that j-thing, only in Go.
  151. go-chi/chi shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    lightweight, idiomatic and composable router for building Go HTTP services
  152. go-martini/martini shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Classy web framework for Go
    知名 Go Web 框架
  153. golang/groupcache shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.
    知名 Go 缓存库
  154. bettercap/bettercap shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    The Swiss Army knife for 802.11, BLE, IPv4 and IPv6 networks reconnaissance and MITM attacks.
  155. getlantern/lantern shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Lantern 官方版本下载 蓝灯 翻墙 代理 科学上网 外网 加速器 梯子 路由 lantern proxy vpn censorship-circumvention censorship gfw accelerator
  156. kubernetes/dashboard shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    General-purpose web UI for Kubernetes clusters
  157. micro/micro shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    API first development platform
  158. gopherjs/gopherjs shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A compiler from Go to JavaScript for running Go code in a browser
  159. halfrost/Halfrost-Field shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    ✍🏻 这里是写博客的地方 —— Halfrost-Field 冰霜之地
  160. containerd/containerd shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An open and reliable container runtime
  161. argoproj/argo-workflows shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Workflow engine for Kubernetes
  162. hashicorp/nomad shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
  163. elastic/beats shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    :tropical_fish: Beats - Lightweight shippers for Elasticsearch & Logstash
  164. nats-io/nats-server shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    High-Performance server for NATS.io, the cloud and edge native messaging system.
  165. json-iterator/go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A high-performance 100% compatible drop-in replacement of "encoding/json"
  166. tomnomnom/gron shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Make JSON greppable!
  167. dgraph-io/badger shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Fast key-value DB in Go.
  168. ent/ent shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An entity framework for Go
  169. containrrr/watchtower shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A process for automating Docker container base image updates.
  170. dolthub/dolt shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Dolt – It's Git for Data
  171. talkgo/night shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Weekly Go Online Meetup via Bilibili | Go 夜读|通过 bilibili 在线直播的方式分享 Go 相关的技术话题,每天大家在微信/telegram/Slack 上及时沟通交流编程技术话题。
  172. geektutu/7days-golang shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    7 days golang programs from scratch (web framework Gee, distributed cache GeeCache, object relational mapping ORM framework GeeORM, rpc framework GeeRPC etc) 7 天用 Go 动手写/从零实现系列
  173. FiloSottile/age shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
  174. ardanlabs/gotraining shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Go Training Class Material :
  175. google/grumpy shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Grumpy is a Python to Go source code transcompiler and runtime.
  176. go-playground/validator shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    :100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
  177. rqlite/rqlite shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    The lightweight, distributed relational database built on SQLite
  178. milvus-io/milvus shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An open-source vector database for scalable similarity search and AI applications.
  179. GoogleContainerTools/kaniko shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Build Container Images In Kubernetes
  180. thanos-io/thanos shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Highly available Prometheus setup with long term storage capabilities. A CNCF Incubating project.
  181. dgrijalva/jwt-go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    ARCHIVE - Golang implementation of JSON Web Tokens (JWT). This project is now maintained at:
  182. golangci/golangci-lint shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Fast linters Runner for Go
  183. tidwall/gjson shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Get JSON values quickly - JSON parser for Go
  184. git-lfs/git-lfs shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Git extension for versioning large files
  185. sqshq/sampler shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.
  186. OpenDiablo2/OpenDiablo2 shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An open source re-implementation of Diablo 2
  187. goreleaser/goreleaser shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Deliver Go binaries as fast and easily as possible
  188. mailhog/MailHog shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Web and API based SMTP testing
    SMTP 工具
  189. github/gh-ost shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    GitHub's Online Schema Migrations for MySQL

#447 Go 练手小项目

2020-12-21

开始在学习 Go 语言了,先在 GitHub 上找一批小项目用来学习。

  1. julienschmidt/httprouter shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A high performance HTTP request router that scales well
  2. golang/groupcache shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.
  3. robfig/cron shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    a cron library for go
  4. jroimartin/gocui shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Minimalist Go package aimed at creating Console User Interfaces.
  5. tylertreat/comcast shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Simulating shitty network connections so you can build better systems.
  6. pkg/errors shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Simple error handling primitives
  7. schachmat/wego shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    weather app for the terminal
  8. teh-cmc/go-internals shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    A book about the internals of the Go programming language.
  9. simeji/jid shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    json incremental digger
  10. patrickmn/go-cache shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications.
  11. wercker/stern shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    ⎈ Multi pod and container log tailing for Kubernetes
  12. allegro/bigcache shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Efficient cache for gigabytes of data written in Go.
  13. microsoft/ethr shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Ethr is a Comprehensive Network Measurement Tool for TCP, UDP & ICMP.
  14. samber/lo shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)
  15. goproxyio/goproxy shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A global proxy for Go modules.
  16. eranyanay/1m-go-websockets shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    handling 1M websockets connections in Go
  17. fogleman/nes shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    NES emulator written in Go.
  1. inconshreveable/ngrok shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    Introspected tunnels to localhost
  2. sirupsen/logrus shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Structured, pluggable logging for Go.
  3. tmrts/go-patterns shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Curated list of Go design patterns, recipes and idioms
  4. gorilla/websocket shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A fast, well-tested and widely used WebSocket implementation for Go.
  5. gorilla/mux shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A powerful HTTP router and URL matcher for building Go web servers with 🦍
  6. julienschmidt/httprouter shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A high performance HTTP request router that scales well
  7. rakyll/hey shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    HTTP load generator, ApacheBench (ab) replacement
  8. ahmetb/kubectx shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Faster way to switch between clusters and namespaces in kubectl
  9. charmbracelet/bubbletea shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A powerful little TUI framework 🏗
  10. jmoiron/sqlx shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    general purpose extensions to golang's database/sql
  11. emirpasic/gods shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w
    GoDS (Go Data Structures) - Sets, Lists, Stacks, Maps, Trees, Queues, and much more
  12. PuerkitoBio/goquery shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A little like that j-thing, only in Go.
  13. go-martini/martini shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Classy web framework for Go
  14. golang/groupcache shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.
  15. FiloSottile/age shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
  16. dgrijalva/jwt-go shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    ARCHIVE - Golang implementation of JSON Web Tokens (JWT). This project is now maintained at:
  17. tidwall/gjson shields.io:github/stars shields.io:github/languages/code-size shields.io:github/commit-activity/w shields.io:github/license
    Get JSON values quickly - JSON parser for Go

#446 gvm: Golang 版本管理

2020-12-19

https://github.com/moovweb/gvm stars license language

安装

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

使用

source ~/.gvm/scripts/gvm

gvm listall

# gvm 默认从 github 克隆代码到本地,然后进行编译
# 可以采用 gitee 仓库加速
git clone git@gitee.com:mirrors/go ~/.gvm/archive/go

gvm install go1.16

gvm list
gvm use go1.16

go version
# go version go1.16 linux/amd64

#445 Golang 结构体

2020-12-18
package main

import (
    "encoding/json"
    "fmt"
    "reflect"
)

type Address struct {
    City    string `json:"city"`
    Country string `json:"country"`
}

type User struct {
    Username string `json:"username"`
    Password string `json:"password"`
}

type Person struct {
    Name    string  `json:"name"`
    Age     int     `json:"age"`
    Address Address `json:"address"`
    // 这么写,JSON 会多一层
    // User    `json:"user"`
    User
}

func (p Person) SayHello() {
    fmt.Println("Hello, my name is", p.Name)
}

func main() {
    person := Person{
        Name: "Bob",
        Age:  30,
        Address: Address{
            City:    "London",
            Country: "UK",
        },
        User: User{
            Username: "bob1999",
            Password: "pa55w0rd",
        },
    }

    // 属性操作
    fmt.Println("Name:", person.Name)
    fmt.Println("Age:", person.Age)
    fmt.Println("City:", person.Address.City)
    fmt.Println("Country:", person.Address.Country)
    fmt.Println("Username:", person.Username)
    fmt.Println("Password:", person.Password)
    fmt.Printf("%+v\n", person)
    fmt.Printf("%#v\n", person)

    // 方法调用
    person.SayHello()

    // 通过反射获取标签内容
    t := reflect.TypeOf(person)
    for i := 0; i < t.NumField(); i++ {
        field := t.Field(i)
        tag := field.Tag.Get("json")
        fmt.Println(field.Name, ":", tag)
    }

    // JSON 序列化
    jsonData, err := json.Marshal(person)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println("JSON:", string(jsonData))
}

// Name: Bob
// Age: 30
// City: London
// Country: UK
// Username: bob1999
// Password: pa55w0rd
// main.Person{name:"Bob", age:30, address:main.Address{city:"London", country:"UK"}, User:main.User{username:"bob1999", password:"pa55w0rd"}}

其他知识点:

  1. 字段名大小写问题:首字母小写的话,只有本包可以访问

  2. Zero-value Struct

type Fruit struct {
    name string
}
var apple Fruit
fmt.Println(apple) // {}
  1. new 关键字
package main

import "fmt"

type Employee struct {
    Name string
    Age  int
}

func main() {
    p := new(Employee)
    fmt.Println(p) // &{ 0}

    var p2 Employee
    fmt.Println(p2) // { 0}

    p3 := Employee{"Me", 30}
    fmt.Println(p3) // {Me 30}
}
  1. struct 字面量
type Person struct {
    Name  string
    Age   int
    Email string
}

p1 := Person{
    Name:  "Alice",
    Age:   25,
    Email: "alice@example.com",
}
p2 := Person {"Alice", 25, "alice@example.com"}
  1. 指针

  2. 匿名结构体

package main

import (
    "fmt"
)

func main() {
    user := struct {
        username string
    }{
        username: "admin",
    }
    fmt.Printf("%+v\n", user)
    // {username:admin}
    fmt.Printf("%#v\n", user)
    // struct { username string }{username:"admin"}
    fmt.Printf("%v\n", user)
    // {admin}
    fmt.Println(user)
    // {admin}
}

场景:

  1. 定义一个临时结构体接收反序列化数据
  2. 内嵌结构体

  3. 匿名属性(或者应该叫啥,我也不知道)

  4. 内嵌类型不能重复,

  5. 前面的例子可以看出,可以直接访问匿名属性(结构体)内部属性,
  6. 但是如果同名就只能老老实实通过类型名字来访问了
package main

import (
    "fmt"
)

type Book struct {
    string // book name (anno field)

    // syntax error: unexpected [, expected field name or embedded type
    // []Author
    Authors []Author // slice of authors

    Publisher
}

type Author struct {
    string // author name (anno field)
}

type Publisher struct {
    string // publisher name (anno field)
}

func main() {
    p := Book{
        string: "Learning Python",
        Authors: []Author{
            {string: "Stanley B.Lippman"},
            {string: "Josée LaJoie"},
            {"Barbara E.Moo"},
        },
        Publisher: Publisher{"人民邮电出版社"},
    }
    p.string = "C++ Primer" // change attr

    fmt.Println(p)
    fmt.Printf("%v\n", p)
    fmt.Printf("%+v\n", p)
    fmt.Printf("%#v\n", p)
    fmt.Printf("%v\n", p.string)
    fmt.Printf("%v\n", p.Authors[0].string)
    fmt.Printf("%v\n", p.Publisher)
    fmt.Printf("%v\n", p.Publisher.string)
}

// {C++ Primer [{Stanley B.Lippman} {Josée LaJoie} {Barbara E.Moo}] {人民邮电出版社}}
// {C++ Primer [{Stanley B.Lippman} {Josée LaJoie} {Barbara E.Moo}] {人民邮电出版社}}
// {string:C++ Primer Authors:[{string:Stanley B.Lippman} {string:Josée LaJoie} {string:Barbara E.Moo}] Publisher:{string:人民邮电出版社}}
// main.Book{string:"C++ Primer", Authors:[]main.Author{main.Author{string:"Stanley B.Lippman"}, main.Author{string:"Josée LaJoie"}, main.Author{string:"Barbara E.Moo"}}, Publisher:main.Publisher{string:"人民邮电出版社"}}
// C++ Primer
// Stanley B.Lippman
// {人民邮电出版社}
// 人民邮电出版社
  1. 将函数通过属性的方式定义
type FoodNameGetter func(string) string

type Food struct {
    name   string
    getter FoodNameGetter // declare function
}

pizza := Food{
    name: "Pizza",
    getter: func(name string) string { // declare function body
        return "This is " + name + "."
    },
}
  1. 结构体比较

如果类型和值相同,就等于。

package main

import "fmt"

type Teacher struct {
    name string
}

type Student struct {
    name string
}

func main() {
    s1 := Student{"John"}
    s2 := Student{"John"}
    fmt.Println(s1 == s2) // true

    // invalid operation: s1 == t1 (mismatched types Student and Teacher)
    // t1 := Teacher{"John"}
    // fmt.Println(s1 == t1)
}

参考资料与拓展阅读

#444 Go 几个特殊用法

2020-12-18

点后直接括号

  1. type assertion 类型断言
  2. type switch 类型判断

Golang 是强类型的语言,这两种语法都是只对 interface{} 有效。

package main

import "fmt"

func test(value interface{}) {
    switch value.(type) {
    case string:
        fmt.Printf("%#v\n", value)
    }
}

func test2(value interface{}) {
    v1, ok := value.([]byte)
    fmt.Printf("%#v, %#v\n", v1, ok)

    v2, ok := value.(string)
    fmt.Printf("%#v, %#v\n", v2, ok)
}

func main() {
    a := "abc"
    test(a)
    test2(a)
}