Skip to content

can't load package: package main #40313

Closed
@fengxinming

Description

@fengxinming

What version of Go are you using (go version)?

$ go version go1.14.6 darwin/amd64

Does this issue reproduce with the latest release?

Code

package main

/*
#include <stdio.h>

int getNumber() {
    return 1;
}
*/
import "C"

import (
	"syscall/js"
)

func main() {
	num := C.getNumber()
	console := js.Global().Get("console")
	console.Get("log").Invoke(1)
}

Build

GOOS=js GOARCH=wasm go build -o static/main.wasm main.go

Error

can't load package: package main: build constraints exclude all Go files in /Users/jesse/workspace/hello-vc/test09

What operating system and processor architecture are you using (go env)?

Switched to branch 'dev/1.4.0'
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jesse/Library/Caches/go-build"
GOENV="/Users/jesse/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jesse/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dq/05143lls7wl6r50lhh9p52y80000gp/T/go-build545878115=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I was going to compile the go file to a wasm file, but it showed error.

What did you expect to see?

the go file will be compiled to a wasm file

What did you see instead?

can't load package: package main: build constraints exclude all Go files in /Users/jesse/workspace/hello-vc/test09

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions