From a327673cd4af3d6c9ccc7b9e3d072aab9dab0a2d Mon Sep 17 00:00:00 2001 From: Antoine Date: Sun, 4 Nov 2018 13:03:27 +0100 Subject: [PATCH] migration gitea --- employee/employee.go | 22 ++++++++++++++++++++++ test.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 employee/employee.go create mode 100644 test.go diff --git a/employee/employee.go b/employee/employee.go new file mode 100644 index 0000000..19b621d --- /dev/null +++ b/employee/employee.go @@ -0,0 +1,22 @@ +package employee + +import ( + "fmt" +) + +type employee struct { + firstName string + lastName string + totalLeaves int + leavesTaken int +} + +// New constructeur d'employee +func New(firstName string, lastName string, totalLeave int, leavesTaken int) (e employee) { + e = employee{firstName, lastName, totalLeave, leavesTaken} + return +} + +func (e employee) LeavesRemaining() { + fmt.Printf("%s %s has %d leaves remaining \n", e.firstName, e.lastName, (e.totalLeaves - e.leavesTaken)) +} diff --git a/test.go b/test.go new file mode 100644 index 0000000..fc1bce0 --- /dev/null +++ b/test.go @@ -0,0 +1,44 @@ +package main + +import ( + "fmt" + //mathRand "math/rand" + cryptoRand "crypto/rand" + "math/big" + "time" + + "main/employee" +) + +var a, b int = 1, 2 + +func main() { + fmt.Println("a+b : ", a+b) + + fmt.Println("Hello, :D ") + fmt.Println("Hello, playground", time.Now()) + + nBig, err := cryptoRand.Int(cryptoRand.Reader, big.NewInt(27)) + if err != nil { + panic(err) + } + n := nBig.Int64() + + //b := []byte{0} + //r := cryptoRand.Reader.Read(b) + fmt.Printf("r (%T) %d\n", n, n) + //fmt.Println("Random", mathRand.Seed(r).Intn(9)) + + e := employee.New("antoine", "roux", 10, 5) + e.LeavesRemaining() +} + +// bool +// string +// int int8 int16 int32 int64 +// uint uint8 uint16 uint32 uint64 uintptr +// byte // alias for uint8 +// rune // alias for int32 +// // represents a Unicode code point +// float32 float64 +// complex64 complex128