Skip to content

Commit d31cf8b

Browse files
committed
updated files information
readme fixes and todos; lowered go requirement to 1.18;
1 parent 9b0d6a5 commit d31cf8b

File tree

16 files changed

+44
-37
lines changed

16 files changed

+44
-37
lines changed

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
11
# Simser
2-
**Sim**ple **ser**ialization code generator for GO structs with unexported fields.
2+
3+
**Sim**ple **ser**ialization code generator for GO structs with unexported fields.
34

45
Like `binary.Read`, but a bit different and without reflection.
56

67
## Features
78

89
### Core
10+
911
- go module mode only
1012
- simple sequential [de]serialization of simple structs
1113
- supports non-exported fields, as well as exported
1214
- basic (`int32`, `float64`, etc.), named (`type My uint64`, etc.) field types, and arrays of them (struct type fields,
13-
array of arrays and slice of arrays are not supported right now)
15+
array of arrays and slice of arrays are not supported right now)
1416
- no reflection in generated code, it is simple and fast
1517
- possibility to select type[s] to serialize via `-types` CLI flag
1618
- customize output function names
1719
- customize output file name
1820

1921
### Advanced
22+
2023
- slice field length can be set to any expression that returns `int`, by using tags. Currently [de]serialized instance can be referred to as "`o`", within expression.
21-
E.g. `simser:"len=o.PreviousIntegerField-5"`.
22-
Or `simser:"len=otherFunc()"`
23-
Remember that only fields that get read _before_ the slice field will have meaningful values (unless some tricks were used)
24+
E.g. `simser:"len=o.PreviousIntegerField-5"`.
25+
Or `simser:"len=otherFunc()"`
26+
Remember that only fields that get read _before_ the slice field will have meaningful values (unless some tricks were used)
2427

2528
## Usage
2629

2730
#### Basic
2831

29-
`//go:generate go run github.com/am4n0w4r/simser -types=Header,body`
30-
`//go:generate go run github.com/am4n0w4r/simser -types=all`
32+
`//go:generate go run github.com/amanofbits/simser -types=Header,body`
33+
`//go:generate go run github.com/amanofbits/simser -types=all`
3134

3235
- `-types` (required): can be a comma-separated list of types you want to process, or reserved keyword `all` for processing all top-level `struct`s, found in file.
33-
`all` usage and requiredness of the argument can change in the future.
36+
`all` usage and requiredness of the argument can change in the future.
3437
- `-output` (optional): set output file name.
3538

3639
#### Custom
3740

38-
`//go:generate go run github.com/am4n0w4r/simser -types=Header -output=file.name -read-fn-name=customReadFnName -write-fn-name=CustomWriteFnName`
41+
`//go:generate go run github.com/amanofbits/simser -types=Header -output=file.name -read-fn-name=customReadFnName -write-fn-name=CustomWriteFnName`
3942

4043
- `-read-fn-name` (optional): custom name for deserializing function. Is set per-file.
4144
- `-write-fn-name` (optional): custom name for deserializing function. Is set per-file.
4245

43-
4446
## Project state
4547

4648
A bit messy, not very optimal, but simple and working. It was developed quickly from scratch, to serve a particular practical purpose, so the code itself is rather not perfect, but generated code should be good and do the job.
47-
It's the first time I worked with go's ast, so it was a lot of try-and-fail behind the scenes. Feel free to file issues.
49+
It's the first time I worked with go's ast, so it was a lot of try-and-fail behind the scenes. Feel free to file issues.
50+
51+
### TODOs
52+
53+
- add field skipping (skip, rskip, wskip tags)
54+
- add `_` fields support (don't assign them on read, just skip n bytes; write customizable padding byte instead)
55+
- add ability to select only r or w functions with flags like `-r[=customFnName]`, `-w[=customFnName]`

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,12 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
module github.com/am4n0w4r/simser
15+
module github.com/amanofbits/simser
1616

1717
// Before Go 1.21, the directive was advisory only; now it is a mandatory requirement
1818
// Source: https://go.dev/doc/modules/gomod-ref#go
19-
// So really no need to set this lower than 1.21
20-
go 1.21
19+
go 1.18
2120

2221
require (
2322
golang.org/x/exp v0.0.0-20231006140011-7918f672742d

internal/domain/domain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

internal/domain/functions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

internal/generator/fstringbuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

internal/generator/generator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
1515
package generator
1616

1717
import (
18-
"github.com/am4n0w4r/simser/internal/domain"
18+
"github.com/amanofbits/simser/internal/domain"
1919
)
2020

2121
func GenStructCode(s domain.InputStruct, out *Output, readFnName, writeFnName string) error {

internal/generator/output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

internal/generator/sizegroups.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
1515
package generator
1616

1717
import (
18-
"github.com/am4n0w4r/simser/internal/domain"
18+
"github.com/amanofbits/simser/internal/domain"
1919
)
2020

2121
// Returns a description of size groups as '[index]size', where:

internal/generator/templates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ import (
1818
"errors"
1919
"fmt"
2020

21-
"github.com/am4n0w4r/simser/internal/domain"
21+
"github.com/amanofbits/simser/internal/domain"
2222
)
2323

2424
// read toRead bytes

internal/parser/input.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 am4n0w4r
1+
// Copyright 2023 amanofbits
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import (
2323
"path/filepath"
2424
"slices"
2525

26-
"github.com/am4n0w4r/simser/internal/domain"
26+
"github.com/amanofbits/simser/internal/domain"
2727
"golang.org/x/mod/modfile"
2828
"golang.org/x/tools/go/packages"
2929
)

0 commit comments

Comments
 (0)