Ask coding questions

← Back to all posts
[Golang] No output?
BlitzNewtron (3)

I cant get my output... what am i supposed to do?

Answered by Coder100 (15394) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (15394)

Hi! That's because in the function you are using return, but not doing anything with that return value. Anyways, I think you're trying to use Println:

package main
import "fmt"

func main() {
  var ThisIsAString string = "Hello!"

  cout(ThisIsAString)
  cout("Hello world!")
}

func cout(arg string) string {
  fmt.Println(arg)
}
SpicedSpices (296)

This is happening because you are not printing anything to the console. At the top of your code under package main, add

import "fmt"

This will allow you to print things to the console.
In function cout() instead of returning string, print it,

func cout(arg string){
  fmt.Println(string)
}