-
Notifications
You must be signed in to change notification settings - Fork 2
Golang: Hello World #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
import "fmt" | ||
|
||
func main() { | ||
fmt.Println("Hello World") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Println("Hello World") | |
fmt.Println("Hello World") |
why fmt.Println
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the Println function of the fmt package , which is similar to the stdio in C. I could have used simple Print or Printf function too. But just that Println adds a new line at the end of the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right but why we would require a new line at the end of output here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't. I just gave it as in C++ we mostly add endl to cout as a practice, so did the same here too. Should I change the function to just Print then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't mix c++
syntax with golang
initially it happens but try not to. And always it what the program requires not on the language. Here, we don't want to a new line after Hello World
right? So, don't use Println
use Print
instead.
I know these are small things but we have to think about these too. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it Subham, Will keep it in mind. Making the changes too.
46300d3
to
abe9699
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 2 commits? please squash the commits.
Also, the commit message is empty.
abe9699
to
94cbc1a
Compare
Resolved, Have squashed the 2 commits to 1 clean commit using git rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still PR title needs to change and commit message is empty
|
the |
In this commit I have showed how to print Hello World in Golang using the fmt package and the Print function. Signed-off-by: Malay Kumar Parida <mparida@redhat.com>
94cbc1a
to
507e9bf
Compare
Sorry Subham, Didn't know the difference between title & message. Corrected now. Have addded a message to the commit. Also would be making the same change in week-2 branch's commit. |
Please update the PR description too (can be the same as commit message) |
Done Yug |
This is my 1st Pull Request. Here I have set up a Golang development environment and executed the first Hello World Program.