diff --git a/learn/Main.go b/learn/Main.go new file mode 100644 index 0000000..64a5f26 --- /dev/null +++ b/learn/Main.go @@ -0,0 +1,12 @@ +package main + +// 引用自定义包 +import unit "go_baselearn/learn/unit" + +/* + * 程序启动入口类 + */ +func main() { + // 调用其他包下方法 + unit.LearnMap() +} diff --git a/src/main/unit/Chapterone.go b/learn/unit/Chapterone.go similarity index 99% rename from src/main/unit/Chapterone.go rename to learn/unit/Chapterone.go index 964b370..96ad4c0 100644 --- a/src/main/unit/Chapterone.go +++ b/learn/unit/Chapterone.go @@ -8,7 +8,6 @@ func learnmap(){ ff.Println("process private method") } - func LearnMap(){ // init map _dict := make(map[string]int) diff --git a/src/app.go b/src/app.go deleted file mode 100644 index fe7f767..0000000 --- a/src/app.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -func main() { - -} diff --git a/src/main/main.go b/src/main/main.go deleted file mode 100644 index 254ddd7..0000000 --- a/src/main/main.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 代码第一行写明package;使用一个文件单独运行的程序必须放在package main下面,否则在go run运行时会报错:”go run: cannot run non-main package“ - */ -package main - -import "fmt" -// 引入自建包 -import uu "main/unit" - - - -func main() { - fmt.Println("Hello Go!") - vari1() - uu.LearnMap(); - var num int= getNum(89); - fmt.Print(num) -} - - -// 语言变量 var v_name v_type -func vari1(){ - // string - var name string = "Lucas" - // print - fmt.Println(name) - // int - var age int = 18; - fmt.Println(name,"的年龄", age) - - - - - // bool 默认false - var c bool - fmt.Println(c) -} -/* - * go 函数 - * - */ -func getNum(arr int) int{ - var varnum int - for a := 0;arr > 0 ;arr= arr/10 { - varnum = (varnum * 10 )+ (arr%10) - a = a+1 - } - return varnum -} - - - - - -