Skip to content

Commit 5ebcb5e

Browse files
authored
Merge pull request #3 from golang-infrastructure/dev
refactor
2 parents 821882f + 3a03da8 commit 5ebcb5e

File tree

12 files changed

+13
-1494
lines changed

12 files changed

+13
-1494
lines changed

.README_images/26e47025.png

-31.9 KB
Binary file not shown.

README.md

+9-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
# Golang的三元表达式实现
22

3-
# 开发初衷
3+
# 一、开发初衷
44

5-
Golang中缺少三元表达式,就导致某些情况三元表达式一行就能搞定的事情到Golang里面就得写得很啰嗦, 这是无法忍受的,这个库就是借助大量自定义的if函数来实现类似三元表达式的功能。
5+
Golang中缺少三元表达式,就导致某些情况三元表达式一行就能搞定的事情到Golang里面就得写得很啰嗦,
6+
这是无法忍受的,这个库就是借助大量自定义的if函数来实现类似三元表达式的功能。
67

7-
## 引入依赖
8-
9-
非泛型版本:
10-
11-
```
12-
go get -u github.com/golang-infrastructure/go-if-expression/v1
13-
```
14-
15-
泛型版本:
8+
## 二、引入依赖
169

1710
```text
18-
go get -u github.com/golang-infrastructure/go-if-expression/v2
11+
go get -u github.com/golang-infrastructure/go-if-expression
1912
```
2013

21-
# V1 Example
22-
23-
所有的API都在if_expression包下,根据三元表达式返回的不同类型有不同的名字:
24-
![](.README_images/26e47025.png)
14+
# 三、 Example
2515

2616
比如最常见的默认值场景:
2717

@@ -30,16 +20,14 @@ threadNum := 0
3020
fmt.Printf("线程数: %d", if_expression.ReturnInt(threadNum == 0, 1, threadNum))
3121
```
3222

33-
34-
35-
# V2 Example
23+
使用的例子:
3624

3725
```go
3826
package main
3927

4028
import (
4129
"fmt"
42-
if_expression "github.com/golang-infrastructure/go-if-expression/v2"
30+
if_expression "github.com/golang-infrastructure/go-if-expression"
4331
)
4432

4533
func main() {
@@ -50,5 +38,6 @@ func main() {
5038
//
5139

5240
}
41+
5342
```
5443

v2/example/main.go example/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/golang-infrastructure/go-if-expression/v2/pkg/if_expression"
5+
if_expression "github.com/golang-infrastructure/go-if-expression"
66
)
77

88
func main() {

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/golang-infrastructure/go-if-expression
2+
3+
go 1.18
File renamed without changes.
File renamed without changes.

v1/examples/default_value.go

-13
This file was deleted.

v1/go.mod

-3
This file was deleted.

0 commit comments

Comments
 (0)