From 1f888759baff90d11639f9d9560f5de6161c5f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Thu, 4 Jan 2024 10:30:51 +0300 Subject: [PATCH] initial commit with BSD-3-Clause --- LICENSE | 28 +++++++++++++++++++++++ README.md | 34 +++++++++++++++++++++++++++ conditionals/demo1.go | 24 ++++++++++++++++++++ conditionals/demo2.go | 25 ++++++++++++++++++++ conditionals/workshop1.go | 26 +++++++++++++++++++++ go.mod | 3 +++ loops/forloopdemo1.go | 21 +++++++++++++++++ loops/forloopdemo2.go | 10 ++++++++ loops/workshop1.go | 20 ++++++++++++++++ main.go | 15 ++++++++++++ variables/demo1.go | 48 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 254 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 conditionals/demo1.go create mode 100644 conditionals/demo2.go create mode 100644 conditionals/workshop1.go create mode 100644 go.mod create mode 100644 loops/forloopdemo1.go create mode 100644 loops/forloopdemo2.go create mode 100644 loops/workshop1.go create mode 100644 main.go create mode 100644 variables/demo1.go diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b2a4661 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2024 Mert Gör and contributors + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a531d97 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# Go Kursu + +Go Programlama dili kursu. BTK AKADEMİ notlarından yararlanılmıştır. Go dili BSD 3 Clause lisanslı olduğundan otomatik olarak bu lisans atanmıştır. + +# License + +BSD 3-Clause License + +Copyright (c) 2024 Mass Collaboration Labs and contributors + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/conditionals/demo1.go b/conditionals/demo1.go new file mode 100644 index 0000000..c54d541 --- /dev/null +++ b/conditionals/demo1.go @@ -0,0 +1,24 @@ +package conditionals + +import "fmt" + +func Demo1() { + var account float64 = 100 + var money float64 = 10 + + var state bool + + state = money > account + + if state { + fmt.Print("not enough money ") + } + + if money <= account { + fmt.Println("your money is getting ready") + account = account - money + fmt.Printf("account is : %v\n", account) + } + // fmt.Println("done. money in account : " + fmt.Sprintf("%v", account)) + // fmt.Printf("done. money in account : %v", account) +} diff --git a/conditionals/demo2.go b/conditionals/demo2.go new file mode 100644 index 0000000..ccd3a82 --- /dev/null +++ b/conditionals/demo2.go @@ -0,0 +1,25 @@ +package conditionals + +import "fmt" + +func Demo2() { + var account float64 = 1000 + var money float64 = 11000 + + if money > account { + fmt.Println("not enough money") + } else if money == account { + fmt.Println("your money is getting ready") + fmt.Println("warning ! no money in account") + } else { + fmt.Println("your money is getting ready") + } + + // if condition { + // if condition { + + // } + // // code + // } + +} diff --git a/conditionals/workshop1.go b/conditionals/workshop1.go new file mode 100644 index 0000000..78aff12 --- /dev/null +++ b/conditionals/workshop1.go @@ -0,0 +1,26 @@ +package conditionals + +import "fmt" + +func Demo3() { + // thre int variables defined + // print screen the max int + + // var a int = 1 + // var b int = 2 + // var c int = 3 + + var number1, number2, number3 int = 10, 5, 18 + + var max int = number1 + + if number2 > max { + max = number2 + } + + if number3 > max { + max = number3 + } + + fmt.Printf("max number is: %v\n", max) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5526a27 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module golesson + +go 1.21.5 diff --git a/loops/forloopdemo1.go b/loops/forloopdemo1.go new file mode 100644 index 0000000..22f5cd6 --- /dev/null +++ b/loops/forloopdemo1.go @@ -0,0 +1,21 @@ +package loops + +import "fmt" + +func Demo1() { + var text string = "Hello World !\n" + // fmt.Println(text) + // fmt.Println(text) + // fmt.Println(text) + // fmt.Println(text) + // fmt.Println(text) + + i := 1 + + for i <= 10 { + fmt.Println(text) + i = i + 1 + } + + fmt.Println("Done !") +} diff --git a/loops/forloopdemo2.go b/loops/forloopdemo2.go new file mode 100644 index 0000000..950b504 --- /dev/null +++ b/loops/forloopdemo2.go @@ -0,0 +1,10 @@ +package loops + +import "fmt" + +func Demo2() { + for i := 1; i <= 10; i++ { + fmt.Println(i) + } + fmt.Println("done\n") +} \ No newline at end of file diff --git a/loops/workshop1.go b/loops/workshop1.go new file mode 100644 index 0000000..cd9555e --- /dev/null +++ b/loops/workshop1.go @@ -0,0 +1,20 @@ +package loops + +import "fmt" + +func Demo3() { + number_in_my_mind := 80 + guess_number := 0 + + fmt.Println("Guess a number: ") + fmt.Scanln(&guess_number) + fmt.Println(guess_number) + + if guess_number == number_in_my_mind { + fmt.Println("correct !") + } else if guess_number < number_in_my_mind { + fmt.Println("lower") + } else { + fmt.Println("bigger") + } +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..0e644b1 --- /dev/null +++ b/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "golesson/conditionals" + "golesson/loops" + "golesson/variables" +) + +func main() { + variables.Demo1() + fmt.Print() + conditionals.Demo3() + loops.Demo3() +} diff --git a/variables/demo1.go b/variables/demo1.go new file mode 100644 index 0000000..37f29a0 --- /dev/null +++ b/variables/demo1.go @@ -0,0 +1,48 @@ +package variables + +import "fmt" + +func Demo1() { + /** + fmt.Print("Hello World !") + fmt.Print("Hello World !") + fmt.Print("Hello World !") + fmt.Print("Hello World !") + fmt.Print("Hello World !")**/ + // fmt.Print("Dünya") + // fmt.Print("!") + var text string = "Hello World !" + fmt.Println(text) + fmt.Println(text) + fmt.Println(text) + fmt.Println(text) + fmt.Println(text) + fmt.Println(text) + + var tax1 int = 15 + + fmt.Println(tax1) + fmt.Println(100 + (100 * 10 / 100)) + fmt.Println() + + var tax2 float32 = 0.1 + + fmt.Println(tax2) + fmt.Println(100 + 100*tax2) + + tax3 := 25.2 + //tax3 = "Engin" + fmt.Println(tax3) + fmt.Printf("data type: %T\n", tax3) + + var statement bool + + var text1 string = "Engin" + var text2 string = "Ahmet" + + statement = text1 != text2 + + fmt.Println(statement) + + fmt.Println(!statement) +}