-2

The code is

fmt.Println("Enter a number : ") // a new line is automatically printed here. How to cancel that ?
fmt.Scanln(&a)

The output is

Enter a number : 
45

I want the output as

Enter a number : 45
Emile Pels
  • 3,837
  • 1
  • 15
  • 23

2 Answers2

3

A quick look at the docs for the fmt package would have found fmt.Print:

fmt.Print("Enter a number : ")
Marc
  • 19,394
  • 6
  • 47
  • 51
0

Simply use:

fmt.Print("Enter a number : ")
Sheikh
  • 539
  • 1
  • 7
  • 29
Sintuz
  • 502
  • 5
  • 14