# How can I tell if I'm printing to stdout or stderr?

**URL:** <https://forum.codecrafters.io/t/how-can-i-tell-if-im-printing-to-stdout-or-stderr/1382>\
**Category:** Challenges\
**Tags:** challenge:interpreter\
**Created:** [August 12, 2024, 1:55am UTC](https://forum.codecrafters.io/t/how-can-i-tell-if-im-printing-to-stdout-or-stderr/1382 "2024-08-12T01:55:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apmsabee](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/apmsabee/32/1270_2.png) [@apmsabee](https://forum.codecrafters.io/u/apmsabee)\
**Post date:** [August 12, 2024, 1:55am UTC](https://forum.codecrafters.io/t/how-can-i-tell-if-im-printing-to-stdout-or-stderr/1382/1 "2024-08-12T01:55:53Z")

</div>

I’m stuck on Stage #EA6 - It seems to me like I’m outputting the right things, but I guess it must be going to stdout somehow. I’ve tried using a logger instead, I’ve tried changing between fmt.Fprintf and println, I’m not sure why my output isn’t being seen by the tester.

Here are my logs:

```auto
remote: [tester::#EA6] Running tests for Stage #EA6 (Scanning: Lexical errors)
remote: [tester::#EA6] [test-1] Running test case: 1
remote: [tester::#EA6] [test-1] Writing contents to ./test.lox:
remote: [tester::#EA6] [test-1] [test.lox] @
remote: [tester::#EA6] [test-1] $ ./your_program.sh tokenize test.lox
remote: [your_program] Logs from your program will appear here!
remote: [your_program] EOF null
remote: [your_program] [Line 1] Error: Unexpected character: @
remote: [tester::#EA6] [test-1] ? [line 1] Error: Unexpected character: @
remote: [tester::#EA6] [test-1] Skipped 2 lines that didn't start with [line N]
remote: [tester::#EA6] [test-1] Expected line #1 on stderr to be "[line 1] Error: Unexpected character: @", but didn't find line
remote: [tester::#EA6] [test-1] Test failed

```

And here’s a snippet of my code:

```go
convertedContents := (string)(fileContents)
	cleanRun := true

	if len(convertedContents) > 0 {
		for index, char := range convertedContents {
			if scanned, validFile := tokens[char]; validFile {
				fmt.Println(scanned)
			} else {
				line := strings.Count(convertedContents[0:index], "\n") + 1
				fmt.Fprintf(os.Stderr, "[Line %d] Error: Unexpected character: %c", line, char)
				cleanRun = false
			}

		}
		fmt.Println("EOF null")

```

---

<div class="post-metadata">

**Author:** ![dpassage](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/dpassage/32/1258_2.png) [@dpassage](https://forum.codecrafters.io/u/dpassage)\
**Post date:** [August 12, 2024, 2:51am UTC](https://forum.codecrafters.io/t/how-can-i-tell-if-im-printing-to-stdout-or-stderr/1382/2 "2024-08-12T02:51:52Z")

</div>

I think your snippet is correctly printing to stderr.

I’d check your output and remember that computers tend to take things ~~L~~ literally.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [August 17, 2024, 2:52am UTC](https://forum.codecrafters.io/t/how-can-i-tell-if-im-printing-to-stdout-or-stderr/1382/3 "2024-08-17T02:52:49Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
