From 0a7a9c2b4514f10c5f5127402c29d8ccfe3e3ba7 Mon Sep 17 00:00:00 2001 From: ZGGSONG Date: Tue, 15 Mar 2022 09:52:04 +0800 Subject: [PATCH] update module --- moduledemo/calc/calcdemo.go | 17 +++++++++++++++++ moduledemo/go.mod | 3 +++ moduledemo/main.go | 15 +++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 moduledemo/calc/calcdemo.go create mode 100644 moduledemo/go.mod create mode 100644 moduledemo/main.go diff --git a/moduledemo/calc/calcdemo.go b/moduledemo/calc/calcdemo.go new file mode 100644 index 0000000..a20ca39 --- /dev/null +++ b/moduledemo/calc/calcdemo.go @@ -0,0 +1,17 @@ +package calc + +func Add(a, b float64) float64 { + return a + b +} + +func Sub(a, b float64) float64 { + return a - b +} + +func Mult(a, b float64) float64 { + return a * b +} + +func Divi(a, b float64) float64 { + return a / b +} diff --git a/moduledemo/go.mod b/moduledemo/go.mod new file mode 100644 index 0000000..e6b2088 --- /dev/null +++ b/moduledemo/go.mod @@ -0,0 +1,3 @@ +module moduledemo + +go 1.17 diff --git a/moduledemo/main.go b/moduledemo/main.go new file mode 100644 index 0000000..9f37a5b --- /dev/null +++ b/moduledemo/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "moduledemo/calc" +) + +func main() { + var a, b float64 + a, b = 6, 3 + fmt.Println(calc.Add(a, b)) + fmt.Println(calc.Sub(a, b)) + fmt.Println(calc.Mult(a, b)) + fmt.Println(calc.Divi(a, b)) +}