Skip to content

Commit 602acda

Browse files
committed
Added module creation tutorial solution on go
1 parent b7084b8 commit 602acda

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

Create_a_GO_module/MoshiMoshi/go.mod

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module aniket-batabyal.com/moshimoshi
2+
3+
go 1.20
4+
5+
replace aniket-batabyal.com/greetings => ../greetings
6+
7+
require aniket-batabyal.com/greetings v0.0.0-00010101000000-000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"aniket-batabyal.com/greetings"
7+
)
8+
9+
func main() {
10+
fmt.Println("Moshi Moshi guys!")
11+
fmt.Println(greetings.GreetUser("Aniket"))
12+
}

Create_a_GO_module/greetings/go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module aniket-batabyal.com/greetings
2+
3+
go 1.20
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package greetings
2+
3+
import "fmt"
4+
5+
// function names starting with Capital letters are called exported names
6+
7+
func GreetUser(name string) string {
8+
message := fmt.Sprintf("Hey, welcome to my channel %v", name)
9+
return message
10+
}

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# learn_golang
2-
This consists of all the codes in the golang tutorial -> https://go.dev/doc/tutorial/
2+
3+
This consists of all the codes in the golang tutorial -> <https://go.dev/doc/tutorial/>
4+
5+
6+
* Things that I have learnt
7+
* How to create a go file
8+
* Step 1: Create a folder `mkdir <folderName>`
9+
* Step 2: Go inside that folder & run cmd as `go mod init <domain>/<packageName>`
10+
* Step 3: Create a go module by creating a new file `[fileName].go`
11+
* Step 4: Write some basic go code in it and to run it type `go run .` or `go run <fileName>`
12+
13+
* [TBD]

0 commit comments

Comments
 (0)