-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Muarine
committed
Apr 10, 2017
1 parent
43dc5dd
commit be48b6d
Showing
36 changed files
with
7,886 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
layout: post | ||
title: 常用算法 | ||
categories: algorithm | ||
description: 算法 | ||
keywords: algorithm, 算法 | ||
--- | ||
|
||
algorithm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
layout: post | ||
title: golang学习-01 | ||
categories: golang | ||
description: golang学习-01 | ||
--- | ||
|
||
##go客户端安装## | ||
https://golang.org/doc/install | ||
|
||
###go环境变量### | ||
|
||
```shell | ||
GOPATH=/Users/Muarine/go | ||
PATH=$PATH:$GOPATH/bin | ||
``` | ||
|
||
### 构建go开发目录 | ||
|
||
```shell | ||
mkdir $GOPATH/github.com/src/hello | ||
``` | ||
|
||
### 选择IDE | ||
|
||
我选择的是Web Storm,对于市面上流行的开发工具体验比较了一下 | ||
|
||
Web Storm 因习惯于IDEA,所以上手非常快,安装golang插件后,可以直接debug | ||
|
||
国产LiteIDE 不用Eclipse标识对界面无爱,果断放弃,而且使用习惯难以接受 | ||
|
||
Atom go-plus plugins 介于使用频率较高,就顺带体验了一下,import 外部package、Test提示、联想输入、语法提示什么的很顺手 | ||
|
||
Sublime Text 还没体验过。。。 | ||
|
||
### 开始学习 | ||
|
||
```shell | ||
go get golang.org/x/tour/gotour | ||
vim $GOPATH/src/github.com/src/hello/hello.go | ||
``` | ||
|
||
```go | ||
// 声明包名 主程序执行入口包名一般为main | ||
package main | ||
import "fmt" | ||
// 程序执行入口 | ||
func main(){ | ||
fmt.Printf("hello world \n") | ||
} | ||
``` | ||
|
||
```shell | ||
go build $GOPATH/src/github.com/src/hello | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
--- | ||
layout: post | ||
title: Println Fprintf Printf 占位符 | ||
categories: golang | ||
description: Println Fprintf Printf 占位符 | ||
--- | ||
|
||
## Println Fprintf Printf 占位符## | ||
|
||
fmt.Println 打印值 | ||
|
||
fmt.Fprintf 指定输出对象 | ||
|
||
fmt.Printf(format string) 输出字符串 | ||
|
||
| 占位符 | 含义 | | ||
| ---- | ---------------------------------------- | | ||
| %v | 结构体字段值 | | ||
| %+v | 结构体字段和字段值 | | ||
| %#v | 结构体运行的源代码片段 | | ||
| %T | 打印值的类型 | | ||
| %t | 格式化布尔值 | | ||
| %d | 十进制格式化 | | ||
| %b | binary 二进制格式化 | | ||
| %o | 八进制格式化 | | ||
| %x | 十六进制格式化,字母形式为小写 a-f | | ||
| %X | 十六进制格式化,字母形式为小写 A-F | | ||
| %U | Unicode格式:U+1234,等同于 "U+%04X" | | ||
| %c | 整数对应的ascii码值 | | ||
| %x | Hexadecimal 输出十六进制值 | | ||
| %f | 浮点型格式化,如有%5.2f 表示占5个字符位右对齐并保留两位小数, %-5.2f 同上但是左对齐 | | ||
| %e | 科学计数法 | | ||
| %E | 科学计数法 | | ||
| %s | 输出字符串, %6s 表示占六个字符并右对齐,%-6s同上但是左对齐 | | ||
| %p | 输出指针内存地址值 | | ||
| %q | 输出指针内存地址值 | | ||
|
||
|
||
|
||
普通占位符 | ||
|
||
| 占位符 | 说明 | 举例 | 输出 | | ||
| ---- | --------------------- | --------------------- | --------------------------- | | ||
| %v | 相应值的默认格式。只输出字段值 | Printf("%v", people) | {zhangsan} | | ||
| %+v | 打印结构体时,会添加字段名 | Printf("%+v", people) | {Name:zhangsan} | | ||
| %#v | 相应值的Go语法表示,打印包和类型、结构体 | Printf("#v", people) | main.Human{Name:"zhangsan"} | | ||
| %T | 相应值的类型的Go语法表示,类型 | Printf("%T", people) | main.Human | | ||
| %% | 字面上的百分号,并非值的占位符 | Printf("%%") | % | | ||
|
||
布尔占位符 | ||
|
||
| 占位符 | 说明 | 举例 | 输出 | | ||
| ---- | ---------- | ------------------ | ---- | | ||
| %t | true/false | Printf("%b", true) | true | | ||
|
||
整数占位符 | ||
|
||
| 占位符 | 说明 | 举例 | 输出 | | ||
| ---- | ----------------------------- | -------------------- | ------ | | ||
| %b | 二进制表示 | Printf("%b", 5) | 101 | | ||
| %c | 相应Unicode码点所表示的字符 | Printf("%c", 0x4E2D) | 中 | | ||
| %d | 十进制表示 | Printf("%d", 0x12) | 18 | | ||
| %o | 八进制表示 | Printf("%d", 10) | 12 | | ||
| %q | 单引号围绕的字符字面值,由Go语法安全地转义 | Printf("%q", 0x4E2D) | '中' | | ||
| %x | 十六进制表示,字母形式为小写 a-f | Printf("%x", 13) | d | | ||
| %X | 十六进制表示,字母形式为大写 A-F | Printf("%x", 13) | D | | ||
| %U | Unicode格式:U+1234,等同于 "U+%04X" | Printf("%U", 0x4E2D) | U+4E2D | | ||
|
||
浮点数和复数的组成部分(实部和虚部) | ||
| 占位符 | 说明 | 举例 | 输出 | | ||
| ---- | ---------------------------------------- | ---------------------------------------- | ------------ | | ||
| %b | 无小数部分的,指数为二的幂的科学计数法,与 strconv.FormatFloat 的 'b' 转换格式一致。例如 -123456p-78 | | | | ||
| %e | 科学计数法,例如 -1234.456e+78 | Printf("%e", 10.2) | 1.020000e+01 | | ||
| %E | 科学计数法,例如 -1234.456E+78 | Printf("%e", 10.2) | 1.020000E+01 | | ||
| %f | 有小数点而无指数,例如 123.456 | Printf("%f", 10.2) | 10.200000 | | ||
| %g | 根据情况选择 %e 或 %f 以产生更紧凑的(无末尾的0)输出 | Printf("%g", 10.20) | 10.2 | | ||
| %G | 根据情况选择 %E 或 %f 以产生更紧凑的(无末尾的0)输出 | Printf("%G", 10.20+2i) | (10.2+2i) | | ||
| %q | 双引号围绕的字符串,由Go语法安全地转义 | Printf("%q", "Go语言") | "Go语言" | | ||
| %x | 十六进制,小写字母,每字节两个字符 | Printf("%x", "golang") | 676f6c616e67 | | ||
| %X | 十六进制,大写字母,每字节两个字符 | Printf("%X", "golang") 676F6C616E67) | (10.2+2i) | | ||
|
||
字符串与字节切片 | ||
浮点数和复数的组成部分(实部和虚部) | ||
|
||
| 占位符 | 说明 | 举例 | 输出 | | ||
| ---- | ------------------------ | ---------------------------- | ------------ | | ||
| %s | 输出字符串表示(string类型或[]byte) | Printf("%s", []byte("Go语言")) | Go语言 | | ||
| %q | 双引号围绕的字符串,由Go语法安全地转义 | Printf("%q", "Go语言") | "Go语言" | | ||
| %x | 十六进制,小写字母,每字节两个字符 | Printf("%x", "golang") | 676f6c616e67 | | ||
| %X | 十六进制,大写字母,每字节两个字符 | Printf("%X", "golang") | 676F6C616E67 | | ||
|
||
指针 | ||
|
||
| 占位符 | 说明 | 举例 | 输出 | | ||
| ---- | ------------ | --------------------- | -------- | | ||
| %p | 十六进制表示,前缀 0x | Printf("%p", &people) | 0x4f57f0 | | ||
|
||
|
||
其它标记 | ||
|
||
| 占位符 | 说明 | 举例 | 输出 | | ||
| ---- | ---------------------------------------- | ------------------- | -------------- | | ||
| + | 总打印数值的正负号;对于%q(%+q)保证只输出ASCII编码的字符 | Printf("%+q", "中文") | "\u4e2d\u6587" | | ||
| - | 在右侧而非左侧填充空格(左对齐该区域) | | | | ||
| # | 备用格式:为八进制添加前导 0(%#o) 为十六进制添加前导 0x(%#x)或 0X(%#X),为 %p(%#p)去掉前导 0x; | Printf("%#U", '中') | U+4E2D | | ||
| ' ' | (空格)为数值中省略的正负号留出空白(% d);以十六进制(% x, % X)打印字符串或切片时,在字节之间用空格隔开 | | | | ||
| 0 | 填充前导的0而非空格;对于数字,这会将填充移到正负号之后 | | | | ||
|
||
|
||
```go | ||
package main | ||
import "fmt" | ||
import "os" | ||
type point struct { | ||
x, y int | ||
} | ||
func main() { | ||
//Go 为常规 Go 值的格式化设计提供了多种打印方式。例如,这里打印了 point 结构体的一个实例。 | ||
p := point{1, 2} | ||
// %v 只输出结构体中的字段值 | ||
fmt.Printf("%v\n", p) // {1 2} | ||
//如果值是一个结构体,%+v 的格式化输出内容将包括结构体的字段名。 | ||
fmt.Printf("%+v\n", p) // {x:1 y:2} | ||
//%#v 形式则输出这个值的 Go 语法表示。例如,值的运行源代码片段。 | ||
fmt.Printf("%#v\n", p) // main.point{x:1, y:2} | ||
//需要打印值的类型,使用 %T。 | ||
fmt.Printf("%T\n", p) // main.point | ||
//格式化布尔值是简单的。 | ||
fmt.Printf("%t\n", true) // true | ||
//格式化整形数有多种方式,使用 %d进行标准的十进制格式化。 | ||
fmt.Printf("%d\n", 123) // 123 | ||
//这个输出二进制表示形式。 | ||
fmt.Printf("%b\n", 14) //Binary 1110 | ||
//这个输出给定十进制数的对应字符。 超出打印空,不会报错 | ||
fmt.Printf("%c\n", 33) // ! | ||
// %x 提供十六进制编码。 | ||
fmt.Printf("%x\n", 456) //Hexadecimal 1c8 | ||
//对于浮点型同样有很多的格式化选项。使用 %f 进行最基本的十进制格式化。 | ||
fmt.Printf("%f\n", 78.9) // 78.900000 | ||
//%e 和 %E 将浮点型格式化为(稍微有一点不同的)科学技科学记数法表示形式。 | ||
fmt.Printf("%e\n", 123400000.0) // 1.234000e+08 | ||
fmt.Printf("%E\n", 123400000.0) // 1.234000E+08 | ||
//使用 %s 进行基本的字符串输出。 | ||
fmt.Printf("%s\n", "\"string\"") // "string" | ||
//像 Go 源代码中那样带有双引号的输出,使用 %q。 | ||
fmt.Printf("%q\n", "\"string\"") // "\"string\"" | ||
//和上面的整形数一样,%x 输出使用 base-16 编码的字符串,每个字节使用 2 个字符表示。 | ||
fmt.Printf("%x\n", "hex this") // 6865782074686973 | ||
//要输出一个指针的值,使用 %p。 | ||
fmt.Printf("%p\n", &p) // 0x1040a128 | ||
//当输出数字的时候,你将经常想要控制输出结果的宽度和精度,可以使用在 % 后面使用数字来控制输出宽度。默认结果使用右对齐并且通过空格来填充空白部分。 | ||
fmt.Printf("|%6d|%6d|\n", 12, 345) // | 12| 345| | ||
//你也可以指定浮点型的输出宽度,同时也可以通过 宽度.精度 的语法来指定输出的精度。 | ||
fmt.Printf("|%6.2f|%6.2f|\n", 1.2, 3.45) // | 1.20| 3.45| | ||
//要最对齐,使用 - 标志。 | ||
fmt.Printf("|%-6.2f|%-6.2f|\n", 1.2, 3.45) // |1.20 |3.45 | | ||
//你也许也想控制字符串输出时的宽度,特别是要确保他们在类表格输出时的对齐。这是基本的右对齐宽度表示。 | ||
fmt.Printf("|%6s|%6s|\n", "foo", "b") // | foo| b| | ||
//要左对齐,和数字一样,使用 - 标志。 | ||
fmt.Printf("|%-6s|%-6s|\n", "foo", "b") // |foo |b | | ||
//到目前为止,我们已经看过 Printf了,它通过 os.Stdout输出格式化的字符串。Sprintf 则格式化并返回一个字符串而不带任何输出。 | ||
s := fmt.Sprintf("a %s", "string") | ||
fmt.Println(s) // a string | ||
//你可以使用 Fprintf 来格式化并输出到 io.Writers而不是 os.Stdout。 | ||
fmt.Fprintf(os.Stderr, "an %s\n", "error") //an error | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
layout: post | ||
title: 多线程 | ||
categories: Java | ||
description: 多线程 | ||
--- | ||
|
||
## 多线程 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
layout: post | ||
title: 深入理解JVM虚拟机-读书笔记 | ||
categories: JVM | ||
description: 深入理解JVM虚拟机-读书笔记 | ||
--- | ||
|
||
## JVM知识点 | ||
|
||
详见《深入理解JVM虚拟机》读书笔记 | ||
|
||
### 运行时数据区 | ||
### 对象存活判定算法 | ||
### 垃圾收集算法 | ||
### 垃圾收集器 |
Oops, something went wrong.