diff --git a/headFirst/args/data.txt b/headFirst/args/data.txt new file mode 100644 index 0000000..cf0389a --- /dev/null +++ b/headFirst/args/data.txt @@ -0,0 +1,6 @@ +1 +2 +3 +4 +5 +6 \ No newline at end of file diff --git a/headFirst/args/go.mod b/headFirst/args/go.mod new file mode 100644 index 0000000..1da823a --- /dev/null +++ b/headFirst/args/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.24.5 diff --git a/headFirst/args/main b/headFirst/args/main new file mode 100755 index 0000000..c45b6c6 Binary files /dev/null and b/headFirst/args/main differ diff --git a/headFirst/args/main.go b/headFirst/args/main.go new file mode 100644 index 0000000..1726a55 --- /dev/null +++ b/headFirst/args/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "main/sub" + "os" +) + +func jp (mylist ...int) { + for _,i := range mylist { + fmt.Print(i," ") + } +} + +func main() { + args := os.Args[1] + res := sub.Kek(args) + fmt.Println(res) + + jp(1,2,3,4) +} + diff --git a/headFirst/args/sub/sub.go b/headFirst/args/sub/sub.go new file mode 100644 index 0000000..1093167 --- /dev/null +++ b/headFirst/args/sub/sub.go @@ -0,0 +1,20 @@ +package sub + +import ( + "bufio" + "os" + "strconv" +) + +func Kek(fileName string) []int { + var seg []int + counter := 0 + file,_ := os.Open(fileName) + scanner := bufio.NewScanner(file) + for scanner.Scan() { + mid,_ := strconv.ParseInt(scanner.Text(),0,0) + seg = append(seg,int(mid)) + counter++ + } + return seg +} \ No newline at end of file diff --git a/headFirst/fourth/data.txt b/headFirst/fourth/data.txt new file mode 100644 index 0000000..6275511 --- /dev/null +++ b/headFirst/fourth/data.txt @@ -0,0 +1,6 @@ +1 +2 +3 +5 +6 +7 diff --git a/headFirst/fourth/fourth b/headFirst/fourth/fourth new file mode 100755 index 0000000..4402983 Binary files /dev/null and b/headFirst/fourth/fourth differ diff --git a/headFirst/fourth/go.mod b/headFirst/fourth/go.mod new file mode 100644 index 0000000..e3a981f --- /dev/null +++ b/headFirst/fourth/go.mod @@ -0,0 +1,3 @@ +module fourth + +go 1.24.5 diff --git a/headFirst/fourth/main.go b/headFirst/fourth/main.go new file mode 100644 index 0000000..ff08523 --- /dev/null +++ b/headFirst/fourth/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "fmt" + "fourth/sub" +) + + +func main() { + res := sub.Kek("data.txt") + fmt.Println(res) +} \ No newline at end of file diff --git a/headFirst/fourth/sub/sub.go b/headFirst/fourth/sub/sub.go new file mode 100644 index 0000000..1093167 --- /dev/null +++ b/headFirst/fourth/sub/sub.go @@ -0,0 +1,20 @@ +package sub + +import ( + "bufio" + "os" + "strconv" +) + +func Kek(fileName string) []int { + var seg []int + counter := 0 + file,_ := os.Open(fileName) + scanner := bufio.NewScanner(file) + for scanner.Scan() { + mid,_ := strconv.ParseInt(scanner.Text(),0,0) + seg = append(seg,int(mid)) + counter++ + } + return seg +} \ No newline at end of file diff --git a/headFirst/third/go.mod b/headFirst/third/go.mod index bae85df..527b3cc 100644 --- a/headFirst/third/go.mod +++ b/headFirst/third/go.mod @@ -1,3 +1,5 @@ module third go 1.24.5 + +require github.com/headfirstgo/greeting v0.0.0-20190504033635-66e7507184ee // indirect diff --git a/headFirst/third/go.sum b/headFirst/third/go.sum new file mode 100644 index 0000000..def1916 --- /dev/null +++ b/headFirst/third/go.sum @@ -0,0 +1,2 @@ +github.com/headfirstgo/greeting v0.0.0-20190504033635-66e7507184ee h1:Hb9bIxuBldEBCjyExf8LAWdR3V7ikknAHVGfAsP7pA0= +github.com/headfirstgo/greeting v0.0.0-20190504033635-66e7507184ee/go.mod h1:VREJ5Jpvj59lYxvs0Uzt8BtzUg05tqSxp+H67JHSBn8= diff --git a/headFirst/third/main.go b/headFirst/third/main.go index 789f654..be529df 100644 --- a/headFirst/third/main.go +++ b/headFirst/third/main.go @@ -1,8 +1,28 @@ package main -import "fmt" +import ( + "fmt" + "strings" + "third/sub" + + "github.com/headfirstgo/greeting" +) + +func hi(input *string) string { + if strings.TrimSpace(*input) == "kek" { + return "" + } + *input = "func" + return fmt.Sprintf("Hi from %s",*input) +} func main() { - lol := 0.4444 - fmt.Printf("\nthis is float %#v\n",lol) + input := "lol" + fmt.Printf("Got from func: %s\n",hi(&input)) + fmt.Printf("Original one: %s\n\n\n\n",input) + + sub.Hello() + sub.Hi() + + greeting.Hello() } \ No newline at end of file diff --git a/headFirst/third/sub/sub.go b/headFirst/third/sub/sub.go new file mode 100644 index 0000000..a263cd7 --- /dev/null +++ b/headFirst/third/sub/sub.go @@ -0,0 +1,12 @@ +package sub + +import "fmt" + +func Hi() { + fmt.Println("Hi from sub pkg") +} + +// Hello() just prints out another version of greeting +func Hello() { + fmt.Println("Hello from sub package!!") +}