Relationship between Firestore and Go data type conversion


--Go to Firestore data type conversion

--Firestore to Go data type conversion

Firestore data type

Data type conversion from Go to Firestore

Go Firestore
bool Bool
string String
int, int8, int16, int32 and int64 Integer
uint8, uint16 and uint32 Integer
uint, uint64 and uintptr [^6]No good
float32 and float64 Double
[]byte Bytes
time.Time and [^7]*ts.Timestamp Timestamp
[^3]*latlng.LatLng GeoPoint
Slices Array
*firestore.DocumentRef Reference
Maps and structs Map
All types of nil Null

[^ 6]: Because it may have a value that cannot be represented by int64, which is the basis of the integer type. [^ 7]: ts package: ""

Data type conversion from Firestore to Go

Firestore Go
Null nil
Boolean value(Bool) bool
String(String) string
integer(Integer) [^1]int64
Floating point number(Double) [^2]float64
Part-Time Job(Bytes) []byte
Date and time(Timestamp) time.Time
Geographic coordinates(GeoPoint) [^3]*latlng.LatLng
Array(Arrays ) [^4][]interface{}
map(Maps) [^5]map[string]interface{}
reference(References) *firestore.DocumentRefs

[^ 1]: Integer types other than uint, uint64, uintptr (regardless of signed or unsigned) are allowed when set in a structure field. The overflow is detected as an error. [^ 2]: Float32 is also allowed when set in a struct field. The overflow is detected as an error. [^ 3]: latlng package: "" [^ 4]: When set in a structure field, it is recursively entered as a slice or array of any type. Slice will be resized to fit the input value. In an array, the surplus elements are filled with 0, and conversely, if the array is too short, the remainder of the input value is deleted. [^ 5]: When set in the structure field, the key is a string only, the value can be of any type and is entered recursively.

Recommended Posts

Relationship between Firestore and Go data type conversion
[Python] Conversion memo between time data and numerical data
Conversion between unixtime and datetime
Image data type conversion [Python]
Extract Pokemon GO Pokemon data and skill data
The subtle relationship between Gentoo and pip
About the relationship between Git and GitHub
Conversion between singular and plural of words
Python and NumPy numeric type inheritance relationship
Relationship between netfilter, firewalld, iptables and nftables
Exchange encrypted data between Python and C #
Let's visualize the relationship between average salary and industry with XBRL data and seaborn! (7/10)
Mutual conversion between Qiita articles and Jupyter notebook
Conversion between Julian day and Gregorian calendar date
Mutual conversion between fixed point and binary numbers
Differences between glibc, musl libc and go resolvers
Relationship between operators and special methods, try calling numeric methods
Investigating the relationship between ice cream spending and temperature
Investigate the relationship between TensorFlow and Keras in transition
Relationship data learning with numpy and NetworkX (spectral clustering)
Mutual conversion between date and days elapsed from January 1, 2000
I examined the data mapping between ArangoDB and Java
Let's distinguish between data structure manipulation and logic code.
Mutual conversion between JSON and YAML / TOML in Python
Compare "relationship between log and infinity" in Gauche (0.9.4) and Python (3.5.1)