learn

package
v0.0.0-...-30cdb9e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateID

func GenerateID() int64

func Learn01

func Learn01()

首字母大写->可以被外部包使用 首字母小写->只能在包内使用

func Learn02

func Learn02()

func Learn03

func Learn03()

func Learn04

func Learn04()

func Learn05

func Learn05()

func Learn06

func Learn06()

func Learn07

func Learn07()

func Learn08

func Learn08()

func Learn09

func Learn09()

小对象由于值复制时的速度较快,所以适合使用非指针接收器。大对象因为复制性能较低,适合使用指针接收器 在接收器和参数间传递时不进行复制,只是传递指针。

func Learn10

func Learn10()

func Learn11

func Learn11()

func Learn12

func Learn12()

func Learn13

func Learn13()

func Learn14

func Learn14()

func Learn15

func Learn15()

func Learn16

func Learn16()

func Learn17

func Learn17()

select 多路复用

func Learn18

func Learn18()

func Learn19

func Learn19()

func Learn20

func Learn20()

func Learn21

func Learn21()

func Learn22

func Learn22()

func Learn23

func Learn23()

func Learn24

func Learn24()

func ProtectRun

func ProtectRun(entry func())

保护方式允许一个函数

Types

type Cat

type Cat struct {

	// 带有结构体tag的字段
	Type int `json:"type" id:"100"`
	// contains filtered or unexported fields
}

type ChipType

type ChipType int

将int声明为ChipType类型(将ChipType定义为int类型)

const (
	None ChipType = iota
	CPU
	GPU
)

func (ChipType) String

func (c ChipType) String() string

当ChipType类型需要显示为字符串时,Go 语言会自动寻找 String() 方法并进行调用 不能在一个非本地的类型上定义新方法(使用处和定义处所在包不同)

type Data

type Data struct {
	// contains filtered or unexported fields
}

type FuncCaller

type FuncCaller func(interface{})

函数定义为类型

func (FuncCaller) Call

func (f FuncCaller) Call(p interface{})

type InnerData

type InnerData struct {
	// contains filtered or unexported fields
}

type Invoker

type Invoker interface {
	//调用时会传入一个 interface{} 类型的变量,这种类型的变量表示任意类型的值
	Call(interface{})
}

type Struct

type Struct struct {
}

func (*Struct) Call

func (s *Struct) Call(p interface{})

(s Struct)也可

type Test

type Test struct {
	// contains filtered or unexported fields
}

type TestInterface

type TestInterface interface {
	// contains filtered or unexported methods
}

type User

type User struct {
	Name    string `json:"name"`
	Age     int
	Address string
	// contains filtered or unexported fields
}

只要是可导出成员(变量首字母大写),都可以转成json。 因成员变量test是不可导出的,故无法转成json 如果变量打上了json标签,如Name旁边的 `json:"name"` , 那么转化成的json key就用该标签“name”,否则取变量名作为key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL