Take user input in Golang

You may use the “Scanln” function to take input from the user in Golang.

In the Go language, the “Scanln” function scans the input texts given as inputs, and saves the respective values into repective arguments.

The following is an instance of taking input from the user:

screenshot of program taking input
Screenshot of code taking input from user.

Save this file now and run it using a command in terminal which seems like this:

go run <filename.go>

Here is the screenshot of output given by this program.

code executed.




Software Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A step-by-step guide on how to start using the WatchData Ethereum API

[Java][LinkedList]Merge Two Sorted Lists #21

| Engineering News-Record

Still Not On GitHub 😲

The Life Cycle of Python Instance Objects

Helium 5G: Cellular Summer

Scalable Integration Testing Method

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Samir Mishra

Samir Mishra

Software Engineer

More from Medium

[Crazy Go Day] Simple Golang Unit Test Implementation

TicTacGo — An Intro to Golang

NSQ Example in Golang

Go package “tuples”