-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1cd23f
commit 8237093
Showing
6 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: gomod | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
schedule: | ||
- cron: '0 0 * * 0' # run "At 00:00 on Sunday" | ||
|
||
# See https://github.com/cristalhq/.github/.github/workflows | ||
jobs: | ||
build: | ||
uses: cristalhq/.github/.github/workflows/[email protected] | ||
|
||
vuln: | ||
uses: cristalhq/.github/.github/workflows/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
# bson | ||
BSON for Go | ||
|
||
[![build-img]][build-url] | ||
[![pkg-img]][pkg-url] | ||
[![version-img]][version-url] | ||
|
||
BSON for Go. | ||
|
||
## Features | ||
|
||
* Simple API. | ||
* Dependency-free. | ||
* Clean and tested code. | ||
|
||
See [docs][pkg-url] for more details. | ||
|
||
## Install | ||
|
||
Go version 1.18+ | ||
|
||
``` | ||
go get github.com/cristalhq/bson | ||
``` | ||
|
||
## Example | ||
|
||
```go | ||
TODO | ||
``` | ||
|
||
See examples: [example_test.go](example_test.go). | ||
|
||
## License | ||
|
||
[MIT License](LICENSE). | ||
|
||
[build-img]: https://github.com/cristalhq/bson/workflows/build/badge.svg | ||
[build-url]: https://github.com/cristalhq/bson/actions | ||
[pkg-img]: https://pkg.go.dev/badge/cristalhq/bson | ||
[pkg-url]: https://pkg.go.dev/github.com/cristalhq/bson | ||
[version-img]: https://img.shields.io/github/v/release/cristalhq/bson | ||
[version-url]: https://github.com/cristalhq/bson/releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package bson | ||
|
||
// Marshaler is the interface implemented by types that | ||
// can marshal themselves into valid BSON. | ||
type Marshaler interface { | ||
MarshalBSON() ([]byte, error) | ||
} | ||
|
||
// Unmarshaler is the interface implemented by types that | ||
// can unmarshal a BSON representation of themselves. | ||
// | ||
// The input can be assumed to be a valid encoding of a BSON. | ||
// UnmarshalBSON must copy the BSON data if it wishes to retain the data after returning. | ||
type Unmarshaler interface { | ||
UnmarshalBSON([]byte) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module bson | ||
|
||
go 1.18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package bson | ||
|
||
// Type represents a BSON type. | ||
type Type byte | ||
|
||
// BSON element types as described in https://bsonspec.org/spec.html. | ||
const ( | ||
TypeDouble Type = 0x01 | ||
TypeString Type = 0x02 | ||
TypeDocument Type = 0x03 | ||
TypeArray Type = 0x04 | ||
TypeBinary Type = 0x05 | ||
TypeUndefined Type = 0x06 | ||
TypeObjectID Type = 0x07 | ||
TypeBool Type = 0x08 | ||
TypeDateTime Type = 0x09 | ||
TypeNull Type = 0x0a | ||
TypeRegex Type = 0x0b | ||
TypeDBPointer Type = 0x0c | ||
TypeCodeWithScope Type = 0x0d | ||
TypeSymbol Type = 0x0e | ||
TypeJavaScriptScope Type = 0x0f | ||
TypeInt32 Type = 0x10 | ||
TypeTimestamp Type = 0x11 | ||
TypeInt64 Type = 0x12 | ||
TypeDecimal Type = 0x13 | ||
TypeMinKey Type = 0xff | ||
TypeMaxKey Type = 0x7f | ||
) |