diff --git a/05 - Calc And Convert/operations/.idea/.gitignore b/05 - Calc And Convert/operations/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/05 - Calc And Convert/operations/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/05 - Calc And Convert/operations/.idea/modules.xml b/05 - Calc And Convert/operations/.idea/modules.xml new file mode 100644 index 0000000..bc5464a --- /dev/null +++ b/05 - Calc And Convert/operations/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/05 - Calc And Convert/operations/.idea/operations.iml b/05 - Calc And Convert/operations/.idea/operations.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/05 - Calc And Convert/operations/.idea/operations.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/05 - Calc And Convert/operations/.idea/vcs.xml b/05 - Calc And Convert/operations/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/05 - Calc And Convert/operations/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/05 - Calc And Convert/operations/go.mod b/05 - Calc And Convert/operations/go.mod new file mode 100644 index 0000000..4d5a072 --- /dev/null +++ b/05 - Calc And Convert/operations/go.mod @@ -0,0 +1,3 @@ +module operations + +go 1.20 diff --git a/05 - Calc And Convert/operations/main.go b/05 - Calc And Convert/operations/main.go new file mode 100644 index 0000000..0159b48 --- /dev/null +++ b/05 - Calc And Convert/operations/main.go @@ -0,0 +1,16 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello,Operations") + + add() +} + +func add() { + value := 10.2 + fmt.Println("value:", value) + value++ + fmt.Println("value:", value) +} diff --git a/07-Array And List And Map/Collections/.idea/.gitignore b/07-Array And List And Map/Collections/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/07-Array And List And Map/Collections/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/07-Array And List And Map/Collections/.idea/Collections.iml b/07-Array And List And Map/Collections/.idea/Collections.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/07-Array And List And Map/Collections/.idea/Collections.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/07-Array And List And Map/Collections/.idea/modules.xml b/07-Array And List And Map/Collections/.idea/modules.xml new file mode 100644 index 0000000..5ed3b80 --- /dev/null +++ b/07-Array And List And Map/Collections/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/07-Array And List And Map/Collections/.idea/vcs.xml b/07-Array And List And Map/Collections/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/07-Array And List And Map/Collections/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/07-Array And List And Map/Collections/go.mod b/07-Array And List And Map/Collections/go.mod new file mode 100644 index 0000000..47facf1 --- /dev/null +++ b/07-Array And List And Map/Collections/go.mod @@ -0,0 +1,3 @@ +module Collections + +go 1.22 diff --git a/07-Array And List And Map/Collections/main.go b/07-Array And List And Map/Collections/main.go new file mode 100644 index 0000000..c684f73 --- /dev/null +++ b/07-Array And List And Map/Collections/main.go @@ -0,0 +1,89 @@ +package main + +import ( + "fmt" + "reflect" +) + +func main() { + collections() + collections1() + collections2() + arrayCollection() + arrayCollection1() +} + +func collections() { + fmt.Println("\ncollections:") + names := []string{"James", "Bond", "Chloe"} + names = append(names, "Mike", "Mary") + fmt.Println(names) + for i, v := range names { + fmt.Println(i, v) + } + fmt.Println(reflect.TypeOf(names)) + fmt.Println(len(names)) + fmt.Println(cap(names)) +} + +func collections1() { + fmt.Println("\ncollections1:") + names := make([]string, 3) + names[0] = "James" + names[1] = "Bond" + names[2] = "Chloe" + fmt.Println(names) + fmt.Println(reflect.TypeOf(names)) + fmt.Println(len(names)) + fmt.Println(cap(names)) +} + +func collections2() { + fmt.Println("\ncollections2:") + names := make([]string, 3, 6) + names[0] = "James" + names[1] = "Bond" + names[2] = "Chloe" + + appendedNames := append(names, "Mike", "Mary") + + names[0] = "James1" + + fmt.Println("names:", names) + fmt.Println("appendedNames:", appendedNames) + +} + +func arrayCollection() { + fmt.Println("\narrayCollection:") + + products := [4]string{"Apple", "Banana", "Orange", "Hat"} + someNames := products[1:3] + allNames := products[:] + + products[1] = "Mango" + + fmt.Println("products:", products) + fmt.Println("someNames:", someNames) + fmt.Println("someNames len:", len(someNames), " cap:", cap(someNames)) + fmt.Println("allNames:", allNames) + fmt.Println("allNames len:", len(allNames), " cap:", cap(allNames)) +} + +func arrayCollection1() { + fmt.Println("\narrayCollection1:") + + products := [4]string{"Apple", "Banana", "Orange", "Hat"} + someNames := products[1:3] + allNames := products[:] + + products[1] = "Mango" + + someNames = append(someNames, "Mike") + + fmt.Println("products:", products) + fmt.Println("someNames:", someNames) + fmt.Println("someNames len:", len(someNames), " cap:", cap(someNames)) + fmt.Println("allNames:", allNames) + fmt.Println("allNames len:", len(allNames), " cap:", cap(allNames)) +} diff --git a/09-FuncAndTypes/funcTypes/.idea/.gitignore b/09-FuncAndTypes/funcTypes/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/09-FuncAndTypes/funcTypes/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/09-FuncAndTypes/funcTypes/.idea/funcTypes.iml b/09-FuncAndTypes/funcTypes/.idea/funcTypes.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/09-FuncAndTypes/funcTypes/.idea/funcTypes.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/09-FuncAndTypes/funcTypes/.idea/modules.xml b/09-FuncAndTypes/funcTypes/.idea/modules.xml new file mode 100644 index 0000000..d3d3528 --- /dev/null +++ b/09-FuncAndTypes/funcTypes/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/09-FuncAndTypes/funcTypes/.idea/vcs.xml b/09-FuncAndTypes/funcTypes/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/09-FuncAndTypes/funcTypes/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/09-FuncAndTypes/funcTypes/go.mod b/09-FuncAndTypes/funcTypes/go.mod new file mode 100644 index 0000000..38bf419 --- /dev/null +++ b/09-FuncAndTypes/funcTypes/go.mod @@ -0,0 +1,3 @@ +module funcTypes + +go 1.22 diff --git a/09-FuncAndTypes/funcTypes/main.go b/09-FuncAndTypes/funcTypes/main.go new file mode 100644 index 0000000..df6b8ab --- /dev/null +++ b/09-FuncAndTypes/funcTypes/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" +) + +//TIP

To run your code, right-click the code and select Run.

Alternatively, click +// the icon in the gutter and select the Run menu item from here.

+ +func main() { + //TIP

Press when your caret is at the underlined text + // to see how GoLand suggests fixing the warning.

Alternatively, if available, click the lightbulb to view possible fixes.

+ s := "gopher" + fmt.Printf("Hello and welcome, %s!\n", s) + + for i := 1; i <= 5; i++ { + //TIP

To start your debugging session, right-click your code in the editor and select the Debug option.

We have set one breakpoint + // for you, but you can always add more by pressing .

+ fmt.Println("i =", 100/i) + } +} \ No newline at end of file