Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6ed0b0e090 | ||
533b265d19 | |||
1ace2631a4 | |||
3dd5ca68d1 | |||
66ccd6021f | |||
e5346f7e4f | |||
|
daf19f031a | ||
5989fd54ca | |||
ed30c26324 | |||
0f8f93d09a | |||
|
f460e2f8dd | ||
70d6a79274 |
51
.gitea/workflows/job_coverage.yml
Normal file
51
.gitea/workflows/job_coverage.yml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
name: coverage
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, v3, v4 ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, v3, v4 ]
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
filter: 'blob:none'
|
||||||
|
|
||||||
|
- name: setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
cache-dependency-path: "**/*.sum"
|
||||||
|
go-version: 'stable'
|
||||||
|
|
||||||
|
- name: test coverage
|
||||||
|
run: |
|
||||||
|
go test -v -cover ./... -coverprofile coverage.out -coverpkg ./...
|
||||||
|
go tool cover -func coverage.out -o coverage.out
|
||||||
|
|
||||||
|
- name: coverage badge
|
||||||
|
uses: tj-actions/coverage-badge-go@v1
|
||||||
|
with:
|
||||||
|
green: 80
|
||||||
|
filename: coverage.out
|
||||||
|
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
id: auto-commit-action
|
||||||
|
with:
|
||||||
|
commit_message: Apply Code Coverage Badge
|
||||||
|
skip_fetch: true
|
||||||
|
skip_checkout: true
|
||||||
|
file_pattern: ./README.md
|
||||||
|
|
||||||
|
- name: Push Changes
|
||||||
|
if: steps.auto-commit-action.outputs.changes_detected == 'true'
|
||||||
|
uses: ad-m/github-push-action@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ github.token }}
|
||||||
|
branch: ${{ github.ref }}
|
@ -1,4 +1,5 @@
|
|||||||
# Micro [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Doc](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/unistack-org/micro/v3?tab=overview) [![Status](https://git.unistack.org/unistack-org/micro/actions/workflows/job_tests.yml/badge.svg?branch=v3)](https://git.unistack.org/unistack-org/micro/actions?query=workflow%3Abuild+branch%3Av3+event%3Apush) [![Lint](https://goreportcard.com/badge/go.unistack.org/micro/v3)](https://goreportcard.com/report/go.unistack.org/micro/v3)
|
# Micro
|
||||||
|
![Coverage](https://img.shields.io/badge/Coverage-45.1%25-yellow)
|
||||||
|
|
||||||
Micro is a standard library for microservices.
|
Micro is a standard library for microservices.
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package codec
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -54,3 +56,22 @@ func (m *RawMessage) UnmarshalJSON(data []byte) error {
|
|||||||
*m = append((*m)[0:0], data...)
|
*m = append((*m)[0:0], data...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalYAML returns m as the JSON encoding of m.
|
||||||
|
func (m *RawMessage) MarshalYAML() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return []byte("null"), nil
|
||||||
|
} else if len(*m) == 0 {
|
||||||
|
return []byte("null"), nil
|
||||||
|
}
|
||||||
|
return *m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalYAML sets *m to a copy of data.
|
||||||
|
func (m *RawMessage) UnmarshalYAML(n *yaml.Node) error {
|
||||||
|
if m == nil {
|
||||||
|
return errors.New("RawMessage UnmarshalYAML on nil pointer")
|
||||||
|
}
|
||||||
|
*m = append((*m)[0:0], []byte(n.Value)...)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package codec
|
package codec
|
||||||
|
|
||||||
|
import "gopkg.in/yaml.v3"
|
||||||
|
|
||||||
// Frame gives us the ability to define raw data to send over the pipes
|
// Frame gives us the ability to define raw data to send over the pipes
|
||||||
type Frame struct {
|
type Frame struct {
|
||||||
Data []byte
|
Data []byte
|
||||||
@ -20,6 +22,17 @@ func (m *Frame) UnmarshalJSON(data []byte) error {
|
|||||||
return m.Unmarshal(data)
|
return m.Unmarshal(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalYAML returns frame data
|
||||||
|
func (m *Frame) MarshalYAML() ([]byte, error) {
|
||||||
|
return m.Marshal()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalYAML set frame data
|
||||||
|
func (m *Frame) UnmarshalYAML(n *yaml.Node) error {
|
||||||
|
m.Data = []byte(n.Value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ProtoMessage noop func
|
// ProtoMessage noop func
|
||||||
func (m *Frame) ProtoMessage() {}
|
func (m *Frame) ProtoMessage() {}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
uuidv8 "github.com/ash3in/uuidv8"
|
uuidv8 "github.com/ash3in/uuidv8"
|
||||||
|
"github.com/google/uuid"
|
||||||
nanoid "github.com/matoous/go-nanoid"
|
nanoid "github.com/matoous/go-nanoid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,6 +97,10 @@ func New(opts ...Option) (string, error) {
|
|||||||
return "", errors.New("invalid option, Type unspecified")
|
return "", errors.New("invalid option, Type unspecified")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ToUUID(s string) uuid.UUID {
|
||||||
|
return uuid.MustParse(s)
|
||||||
|
}
|
||||||
|
|
||||||
// Must is the same as New but fatals on error
|
// Must is the same as New but fatals on error
|
||||||
func MustNew(opts ...Option) string {
|
func MustNew(opts ...Option) string {
|
||||||
id, err := New(opts...)
|
id, err := New(opts...)
|
||||||
|
@ -7,5 +7,14 @@ func TestUUIDv8(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Logf("xxx %s\n", id)
|
_ = id
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestToUUID(t *testing.T) {
|
||||||
|
id, err := New()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
u := ToUUID(id)
|
||||||
|
_ = u
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user