From 46e9d54d07ebf4dfb61be99b170d0749b6cedd8b Mon Sep 17 00:00:00 2001 From: "13715166404@163.com" <13715166404@163.com> Date: Tue, 3 Sep 2019 14:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=8C=85=E6=97=A0=E6=B3=95=E5=BC=95=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- learn/Main.go | 12 ++++++ {src/main => learn}/unit/Chapterone.go | 1 - src/app.go | 5 --- src/main/main.go | 55 -------------------------- 4 files changed, 12 insertions(+), 61 deletions(-) create mode 100644 learn/Main.go rename {src/main => learn}/unit/Chapterone.go (99%) delete mode 100644 src/app.go delete mode 100644 src/main/main.go 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 -} - - - - - -