I can no longer run Go programs

This is the strangest problem I have ever encountered. I have a Go development environment configured on a Windows 2008 R2 virtual machine. I do not even restart it and do not start updating Windows.

Today I just realized that I can no longer run Go programs. I can successfully build and run unit tests with the go test. However, starting any compiled Go program (even a greeting) causes a pop-up window to appear called "Unsupported 16-bit application." The error message is as follows:

The version of this file is incompatible with the version of Windows you are running. Check your computer system information to see if you need the x86 (32-bit) or x64 (64-bit) version and then contact the software publisher.

The result is the same no matter which version of Go I'm using (x86 / x64). Also note that I am not using an IDE. I call go.exe to build / test from the command line.

I can’t think it over, since the work of "go test" works fine.

Any thoughts?

EDIT:

Here is the console output when building and starting the program:

build / run output

Interestingly, dumpbin assumes that something is really wrong with the executable

C:\Program Files (x86)\Microsoft Visual Studio 11.0>dumpbin /headers C:\Projects \GoPlayground\src\playground\playground.exe Microsoft (R) COFF/PE Dumper Version 11.00.51106.1 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file C:\Projects\GoPlayground\src\playground\playground.exe File Type: LIBRARY C:\Projects\GoPlayground\src\playground\playground.exe : warning LNK4003: invali d library format; library ignored C:\Projects\GoPlayground\src\playground\playground.exe : warning LNK4048: Invali d format file; ignored Summary C:\Program Files (x86)\Microsoft Visual Studio 11.0> 

And here is the full source code:

 package playground import "fmt" import "playground/another" func main() { fmt.Println("Hello world!") fmt.Println(another.Foobar(2)) } ------------------- package another func Foobar(i int) int { return i + 1 } 

EDIT2:

I reinstalled Go twice without effect.

+8
go
source share
1 answer

Go programming language specification

Program execution

A complete program is created by linking a single, non-returning package, called the main package with all the packages that it imports, transitively. The main package should contain the name of the main package and declare a main function that takes no arguments and does not return a value.

 func main() { … } 

Program execution begins by initializing the main package, and then calling the main function. When this function call returns, the program exits. He does not wait until other (not main) guests are full.

Use package main , not package playground . For example,

playground.go :

 package main import ( "fmt" "playground/another" ) func main() { fmt.Println("Hello world!") fmt.Println(another.Foobar(2)) } 

playground/another.go :

 package another func Foobar(i int) int { return i + 1 } 

Output:

 Hello world!
 3
+11
source share

All Articles