title: imports syscall/js: build constraints exclude all Go files in /usr/local/go/src/syscall
body: <p>I am trying to use Go api-call function in javascript by converting the Go function into web assembly. To do that I am trying to import <code>syscall/js</code> but it throws the following error:</p>
  <blockquote>
  <p>imports syscall/js: build constraints exclude all Go files in /usr/local/go/src/syscall/js</p>
  </blockquote>
  <pre><code>package main
  
  import (
      &quot;fmt&quot;
      &quot;io/ioutil&quot;
      &quot;net/http&quot;
      &quot;syscall/js&quot; // I can't use  syscall/js
  )
  
  func main() {
      fmt.Println(&quot;Go Web Assembly&quot;)
      js.Global().Set(&quot;getData&quot;, getData)
  }
  
  func getData(string, error) {
      resp, err := http.Get(&quot;https://jsonplaceholder.typicode.com/posts&quot;)
      if err != nil {
          return
      }
      // We Read the response body on the line below.
      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          return
      }
      // Convert the body to type string
      sb := string(body)
      return sb
  }
  </code></pre>