Func函数处理
This commit is contained in:
8
05 - Calc And Convert/operations/.idea/.gitignore
generated
vendored
Normal file
8
05 - Calc And Convert/operations/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
8
05 - Calc And Convert/operations/.idea/modules.xml
generated
Normal file
8
05 - Calc And Convert/operations/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/operations.iml" filepath="$PROJECT_DIR$/.idea/operations.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
9
05 - Calc And Convert/operations/.idea/operations.iml
generated
Normal file
9
05 - Calc And Convert/operations/.idea/operations.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
05 - Calc And Convert/operations/.idea/vcs.xml
generated
Normal file
6
05 - Calc And Convert/operations/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
3
05 - Calc And Convert/operations/go.mod
Normal file
3
05 - Calc And Convert/operations/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module operations
|
||||
|
||||
go 1.20
|
||||
16
05 - Calc And Convert/operations/main.go
Normal file
16
05 - Calc And Convert/operations/main.go
Normal file
@@ -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)
|
||||
}
|
||||
8
07-Array And List And Map/Collections/.idea/.gitignore
generated
vendored
Normal file
8
07-Array And List And Map/Collections/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
9
07-Array And List And Map/Collections/.idea/Collections.iml
generated
Normal file
9
07-Array And List And Map/Collections/.idea/Collections.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
8
07-Array And List And Map/Collections/.idea/modules.xml
generated
Normal file
8
07-Array And List And Map/Collections/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Collections.iml" filepath="$PROJECT_DIR$/.idea/Collections.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
07-Array And List And Map/Collections/.idea/vcs.xml
generated
Normal file
6
07-Array And List And Map/Collections/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
3
07-Array And List And Map/Collections/go.mod
Normal file
3
07-Array And List And Map/Collections/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module Collections
|
||||
|
||||
go 1.22
|
||||
89
07-Array And List And Map/Collections/main.go
Normal file
89
07-Array And List And Map/Collections/main.go
Normal file
@@ -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))
|
||||
}
|
||||
8
09-FuncAndTypes/funcTypes/.idea/.gitignore
generated
vendored
Normal file
8
09-FuncAndTypes/funcTypes/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
9
09-FuncAndTypes/funcTypes/.idea/funcTypes.iml
generated
Normal file
9
09-FuncAndTypes/funcTypes/.idea/funcTypes.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
8
09-FuncAndTypes/funcTypes/.idea/modules.xml
generated
Normal file
8
09-FuncAndTypes/funcTypes/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/funcTypes.iml" filepath="$PROJECT_DIR$/.idea/funcTypes.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
09-FuncAndTypes/funcTypes/.idea/vcs.xml
generated
Normal file
6
09-FuncAndTypes/funcTypes/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
3
09-FuncAndTypes/funcTypes/go.mod
Normal file
3
09-FuncAndTypes/funcTypes/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module funcTypes
|
||||
|
||||
go 1.22
|
||||
21
09-FuncAndTypes/funcTypes/main.go
Normal file
21
09-FuncAndTypes/funcTypes/main.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
//TIP <p>To run your code, right-click the code and select <b>Run</b>.</p> <p>Alternatively, click
|
||||
// the <icon src="AllIcons.Actions.Execute"/> icon in the gutter and select the <b>Run</b> menu item from here.</p>
|
||||
|
||||
func main() {
|
||||
//TIP <p>Press <shortcut actionId="ShowIntentionActions"/> when your caret is at the underlined text
|
||||
// to see how GoLand suggests fixing the warning.</p><p>Alternatively, if available, click the lightbulb to view possible fixes.</p>
|
||||
s := "gopher"
|
||||
fmt.Printf("Hello and welcome, %s!\n", s)
|
||||
|
||||
for i := 1; i <= 5; i++ {
|
||||
//TIP <p>To start your debugging session, right-click your code in the editor and select the Debug option.</p> <p>We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.</p>
|
||||
fmt.Println("i =", 100/i)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user