Skip to content

Commit 393f38e

Browse files
authored
Add section on basic types.
Fix struct types.
1 parent 0dacc8d commit 393f38e

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

generator/README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,44 @@ used to programmatically generate the [Dropbox Go SDK](https://github.com/dropbo
1717

1818
## Generated Code
1919

20+
### Basic Types
21+
22+
Here is how Stone [basic types](https://github.com/dropbox/stone/blob/master/doc/lang_ref.rst#basic-types) map to Go types:
23+
24+
Stone Type | Go Type
25+
---------- | -------
26+
Int32/Int64/UInt32/UInt64 | int32/int64/uint32/uint64
27+
Float32/Float64 | float32/float64
28+
Boolean | bool
29+
String | string
30+
Timestamp | time.Time
31+
Void | struct{}
32+
2033
### Structs
2134

22-
Stone https://github.com/dropbox/stone/blob/master/doc/lang_ref.rst#struct[structs] are represented as Go https://gobyexample.com/structs[structs] in a relatively straight-forward manner.
35+
Stone [structs](https://github.com/dropbox/stone/blob/master/doc/lang_ref.rst#struct) are represented as Go [structs](https://gobyexample.com/structs) in a relatively straight-forward manner. Each struct member is exported and also gets assigned the correct json tag. The latter is used for serializing requests and deserializing responses. Non-primitive types are represented as pointers to the corresponding type.
2336

2437
```
25-
struct Account <1>
38+
struct Account
2639
"The amount of detail revealed about an account depends on the user
27-
being queried and the user making the query." <2>
40+
being queried and the user making the query."
2841
29-
account_id AccountId <3>
30-
"The user's unique Dropbox ID." <4>
31-
name Name <5>
42+
account_id AccountId
43+
"The user's unique Dropbox ID."
44+
name Name
3245
"Details of a user's name."
3346
```
3447

3548
```go
3649
// The amount of detail revealed about an account depends on the user being
37-
// queried and the user making the query. <2>
38-
type Account struct { // <1>
39-
// The user's unique Dropbox ID. <4>
40-
AccountId string `json:"account_id"` // <3>
41-
// Details of a user's name.
42-
Name *Name `json:"name"` // <5>
50+
// queried and the user making the query.
51+
type Account struct {
52+
// The user's unique Dropbox ID.
53+
AccountId string `json:"account_id"`
54+
// Details of a user's name.
55+
Name *Name `json:"name"`
4356
}
4457
```
45-
<1> A struct is defined as a Go struct
46-
<2> The documentation shows up before the struct definition
47-
<3> Each struct member is exported and also gets assigned the correct json tag. The latter is used for serializing requests and deserializing responses.
48-
<4> Member documentation appears above the member definition
49-
<5> Non-primitive types are represented as pointers to the corresponding type
5058

5159
### Unions
5260

0 commit comments

Comments
 (0)