First ideas
parent
504f1a9fef
commit
1ba83c27da
|
@ -0,0 +1,6 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
//Idee: Wordcount nutzt forloops und bisschen logik
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Nur für unseren Vortrag oder damit Leute sich was anschauen können
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt" //Std output library
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var num int = 42;
|
||||
|
||||
var greeting string = "Hallo";
|
||||
|
||||
num2 := -13; // Auch neue Variable, Go erkennt Type am Wert: int
|
||||
|
||||
fmt.Println("Type of num2:", reflect.TypeOf(num2)); //Type of num2: int
|
||||
|
||||
result := num + num2;
|
||||
|
||||
// Variablen müssen, wie in Zig, genutzt werden sonst führt das Programm nicht aus
|
||||
// "declared and not used: num3"
|
||||
|
||||
fmt.Println(greeting);
|
||||
|
||||
fmt.Printf("%d + %d = %d \n", num2, num, result);
|
||||
|
||||
|
||||
text := "Willkommen zu unserem Go Vortrag!";
|
||||
words := strings.Fields(text);
|
||||
|
||||
for index, word := range words {
|
||||
fmt.Printf("%d. Wort: %s \n", index+1, word);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue