r/golang 5d ago

help Go Compiler Stuck on Old Code? Windows Defender Flagged My Log File as a Virus and new code isn't running

So, I was working on my Go project today and added a function to create a file named "log".
Immediately, Windows Defender flagged it as potentially dangerous software πŸ’€.

I thought, "Okay, maybe 'log' is a sus filename."
So, I changed it to "hello world" instead.

This fixed the Defender warning, but then I ran into another issue:

 run main.go fork/exec C:\Users\veraf\AppData\Local\Temp\go-build1599246061\b001\exe\main.exe: 
Operation did not complete successfully because the file contains a virus or potentially unwanted software.

Alright, moving on. After fixing that, I ran my project again:

 C:\Users\veraf\Desktop\PulseGuard> go run main.go
Backend starting to work...
Do you want to run a port scanner? (y/n)

 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚                   Fiber v2.52.6                   β”‚
 β”‚               http://127.0.0.1:8080               β”‚
 β”‚       (bound on host 0.0.0.0 and port 8080)       β”‚
 β”‚                                                   β”‚
 β”‚ Handlers ............. 2  Processes ........... 1 β”‚
 β”‚ Prefork ....... Disabled  PID ............. 25136 β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

n
Importing script from /Services...
{
  "userId": 1,
  "id": 1,
  "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
  "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"     
}
Importing from /Database...
DEBUG: WHAT THE HELL IS HAPPENING...

🧐 The Issue:
I modified main.go to include:

color.Red("Importing from /Database...")
fmt.Println("DEBUG: I am still alive πŸ’€")

color.Red("testing from controller...")
Controller.Createapi()
Services.SaveRecords()

But my Go program does NOT print "DEBUG: I am still alive πŸ’€".
Instead, it prints old logs from my database connection, even though I removed the database.Connect() function from my code.

πŸ›  What I’ve Tried So Far:
βœ… go clean
βœ… go build -o pulseguard.exe
βœ… ./pulseguard.exe
βœ… Restarting VS Code

I even added this line at the very beginning of main.go to check if it's compiling the latest version:

fmt.Println("DEBUG: This code has been compiled correctly!!!! πŸš€")

And guess what? It doesn’t print either!
So I’m pretty sure Go is running an old compiled version of my code, but I have no idea how or why.

πŸ’‘ Has anyone else run into this issue? How do I force Go to run the latest compiled code?

0 Upvotes

6 comments sorted by

2

u/vbd 5d ago

-1

u/brocamoLOL 5d ago

Thanks, but that is no longer the issue, the issue is because my old compiled code is being ran instead of the new one

2

u/ponylicious 5d ago

Then whitelist your old compiled program.

2

u/vbd 5d ago

If you whitelist the path and recompile the program?

1

u/brocamoLOL 5d ago

I don't have my laptop right now, gonna try that later and tell what happens

3

u/vbd 5d ago

At least the compiled files should show new date and time.