mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-20 16:23:53 +01:00
v0.5.0-rc4: fixing autocert issue, cache ACME registration, added ls-config option
This commit is contained in:
@@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
@@ -135,7 +136,7 @@ func (p *BidirectionalPipe) Start() E.NestedError {
|
||||
errCh <- p.pDstSrc.Start()
|
||||
}()
|
||||
for err := range errCh {
|
||||
if err.IsNotNil() {
|
||||
if err.HasError() {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -149,4 +150,20 @@ func (p *BidirectionalPipe) Stop() E.NestedError {
|
||||
func Copy(ctx context.Context, dst io.WriteCloser, src io.ReadCloser) E.NestedError {
|
||||
_, err := io.Copy(dst, StdReadCloser{&ReadCloser{ctx: ctx, r: src}})
|
||||
return E.From(err)
|
||||
}
|
||||
}
|
||||
|
||||
func LoadJson[T any](path string, pointer *T) E.NestedError {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return E.From(err)
|
||||
}
|
||||
return E.From(json.Unmarshal(data, pointer))
|
||||
}
|
||||
|
||||
func SaveJson[T any](path string, pointer *T, perm os.FileMode) E.NestedError {
|
||||
data, err := json.Marshal(pointer)
|
||||
if err != nil {
|
||||
return E.From(err)
|
||||
}
|
||||
return E.From(os.WriteFile(path, data, perm))
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
func ExpectErrNil(t *testing.T, err E.NestedError) {
|
||||
t.Helper()
|
||||
if err.IsNotNil() {
|
||||
if err.HasError() {
|
||||
t.Errorf("expected err=nil, got %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user