packs2
DEV 3 years ago
parent 5701f591c4
commit 22df05cee0

@ -33,7 +33,7 @@ import (
type ErrGroup ErrList type ErrGroup Errs

@ -25,11 +25,11 @@
package errs package errs
type ErrList []error type Errs []error
func (l ErrList) Clean() ErrList { func (l Errs) Clean() Errs {
for _, e := range l { for _, e := range l {
if e == nil { if e == nil {
return l.clean() return l.clean()
@ -39,7 +39,7 @@ func (l ErrList) Clean() ErrList {
} }
func (l ErrList) clean() ErrList { func (l Errs) clean() Errs {
rs := make([]error, 0, len(l)) rs := make([]error, 0, len(l))
for _, e := range l { for _, e := range l {
if e != nil { if e != nil {
@ -50,7 +50,7 @@ func (l ErrList) clean() ErrList {
} }
func (l ErrList) GetFirst() error { func (l Errs) GetFirst() error {
for _, er := range l { for _, er := range l {
if er != nil { if er != nil {
return er return er
@ -60,7 +60,7 @@ func (l ErrList) GetFirst() error {
} }
func (l ErrList) GetLast() error { func (l Errs) GetLast() error {
for i := len(l) - 1; i >= 0; i-- { for i := len(l) - 1; i >= 0; i-- {
if l[i] != nil { if l[i] != nil {
return l[i] return l[i]
@ -70,15 +70,15 @@ func (l ErrList) GetLast() error {
} }
func (l ErrList) Any() bool { func (l Errs) Any() bool {
return l.count(true) > 0 } return l.count(true) > 0 }
func (l ErrList) Count() int { func (l Errs) Count() int {
return _errorsCount(false, l) } return _errorsCount(false, l) }
func (l ErrList) count(ext bool) int { func (l Errs) count(ext bool) int {
rs := 0 rs := 0
for _, er := range l { for _, er := range l {
if er != nil { if er != nil {
@ -92,7 +92,7 @@ func (l ErrList) count(ext bool) int {
} }
func (l ErrList) Stack() StackTrace { func (l Errs) Stack() StackTrace {
for _, er := range l { for _, er := range l {
if er != nil { if er != nil {
st := getStackTrace(er) st := getStackTrace(er)
@ -105,7 +105,7 @@ func (l ErrList) Stack() StackTrace {
} }
func (l ErrList) ToError() error { func (l Errs) ToError() error {
switch _errorsCount(false, l) { switch _errorsCount(false, l) {
case 0: case 0:
return nil return nil

@ -72,7 +72,7 @@ func ToError(err any) error {
case error: case error:
return e return e
case []error: case []error:
return ErrList(e).ToError() return Errs(e).ToError()
default: default:
return ErrCode(fmt.Sprintf("#{er}")) return ErrCode(fmt.Sprintf("#{er}"))
} }

@ -25,23 +25,23 @@ package slices
type String []string type Strings []string
func MakeString(size, capacity int) String { func MakeStrings(size, capacity int) Strings {
return make(String, size, capacity) return make(Strings, size, capacity)
} }
func (s String) Reset() String { func (s Strings) Reset() Strings {
if s != nil { if s != nil {
return s[:0] return s[:0]
} }
return s return s
} }
func (s String) Has(value string) bool { func (s Strings) Has(value string) bool {
if len(s) == 0 { if len(s) == 0 {
return false return false
} }
@ -53,6 +53,6 @@ func (s String) Has(value string) bool {
return false return false
} }
func (s String) Append(value string) String { func (s Strings) Append(value string) Strings {
return append(s, value) return append(s, value)
} }

@ -24,7 +24,6 @@
package values package values
type ( type (
Field interface { Field interface {
@ -36,6 +35,9 @@ type (
func NewField (name string, value any) (Field,error) { func NewField (name string, value any) (Field,error) {
switch value.(type) { switch v := value.(type) {
case string: return NewFieldString(name,v),nil
default:
return nil,nil
} }
} }

@ -0,0 +1,26 @@
// ------------------------------------------------------------------------
// Project atila
// Active Thing (activething.com) git.activething.com/go
//
// File name field_int8.go
// Created by DEV
// Modified 03/03/2024
//
// Copyright 2024 activething.com
// ------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
package values

@ -45,12 +45,24 @@ func NewFieldString (name string, value string) *FieldString {
} }
} }
func (f FieldString) Name () string { func (f FieldString) Name () string {
return f.n } return f.n }
func (f FieldString) Value() string { func (f FieldString) Value() any {
return f.v } return f.v }
func (_ FieldString) FieldType () FieldType { func (_ FieldString) FieldType () FieldType {
return FieldTypeString }
func (f FieldString) String() string {
return f.v }
}

@ -49,7 +49,7 @@ type (
Data any Data any
excludes slices.String excludes slices.Strings
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.