March 2019
Beginner to intermediate
324 pages
7h 17m
English
GopherJS includes a sub-package called js. This package provides the functionalities needed to bridge between Go and JavaScript. The package can be found at https://godoc.org/github.com/gopherjs/gopherjs/js.
The key feature provided by the js package is the ability to transform Go types into JavaScript types, and vice versa.
When we consider data types, there are two main categories that need to be supported: basic types (int, float, and string) and constructed types (structs and interfaces). The following table shows the type mappings between Go basic types and JavaScript types, as supported by GopherJS:
| Go type | JavaScript type |
| bool | Boolean |
| int and float | Number |
| string | String |
| []int8 | Int8Array |
| []int16 | Int16Array ... |
Read now
Unlock full access