Skip to content

Commit

Permalink
Merge pull request #60 from xushiwei/db
Browse files Browse the repository at this point in the history
ydb.Class: query
  • Loading branch information
xushiwei authored Feb 6, 2024
2 parents c0f9cec + 3fe0b0f commit f2bd75e
Show file tree
Hide file tree
Showing 10 changed files with 765 additions and 66 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ go 1.18
require (
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/goplus/gop v1.2.0
github.com/qiniu/x v1.13.3
github.com/qiniu/x v1.13.4-0.20240205192036-55db357e2bdf
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/goplus/gop v1.2.0 h1:1EOUKhr4OitJs0BtVBVVbejuUkLbXMiFparS1VW7Fhg=
github.com/goplus/gop v1.2.0/go.mod h1:F4xOWRMTPCKzNBaF1gZC/JsEKtYW1+Ldwp7tyFoaOWo=
github.com/qiniu/x v1.13.3 h1:NER9aJnVzjH0XapzIWrWNAn2SPwck0xGMyIIlfCMm84=
github.com/qiniu/x v1.13.3/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E=
github.com/qiniu/x v1.13.4-0.20240205192036-55db357e2bdf h1:FCmAN2cuVQWqWd5Mkko0W6Tuc5q2DT+tuz1Ln1zvd7M=
github.com/qiniu/x v1.13.4-0.20240205192036-55db357e2bdf/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E=
2 changes: 1 addition & 1 deletion gop.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gop 1.1
gop 1.2

project _yap.gox App github.com/goplus/yap

Expand Down
16 changes: 16 additions & 0 deletions noredirect/noredirect.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2023 The GoPlus Authors (goplus.org). All rights reserved.
*
* 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 noredirect

import (
Expand Down
30 changes: 30 additions & 0 deletions reflectutil/reflect_go120.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//go:build go1.20
// +build go1.20

/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* 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 reflectutil

import (
"reflect"
)

// SetZero sets v to be the zero value of v's type.
// It panics if CanSet returns false.
func SetZero(v reflect.Value) {
v.SetZero()
}
30 changes: 30 additions & 0 deletions reflectutil/reflect_mock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//go:build !go1.20
// +build !go1.20

/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* 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 reflectutil

import (
"reflect"
)

// SetZero sets v to be the zero value of v's type.
// It panics if CanSet returns false.
func SetZero(v reflect.Value) {
v.Set(reflect.Zero(v.Type()))
}
31 changes: 31 additions & 0 deletions reflectutil/reflect_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* 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 reflectutil

import (
"reflect"
"testing"
)

func TestSetZero(t *testing.T) {
a := 2
v := reflect.ValueOf(&a).Elem()
SetZero(v)
if !v.IsZero() {
t.Fatal("SetZero:", v)
}
}
171 changes: 171 additions & 0 deletions test/logt/logt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* 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 logt

import (
"log"
"runtime"
"time"
)

type T struct {
name string
fail bool
skipped bool
}

func New() *T {
return &T{}
}

func (p *T) Name() string {
return p.name
}

// Fail marks the function as having failed but continues execution.
func (p *T) Fail() {
p.fail = true
}

// Failed reports whether the function has failed.
func (p *T) Failed() bool {
return p.fail
}

// FailNow marks the function as having failed and stops its execution
// by calling runtime.Goexit (which then runs all deferred calls in the
// current goroutine).
// Execution will continue at the next test or benchmark.
// FailNow must be called from the goroutine running the
// test or benchmark function, not from other goroutines
// created during the test. Calling FailNow does not stop
// those other goroutines.
func (p *T) FailNow() {
p.fail = true
runtime.Goexit()
}

// Log formats its arguments using default formatting, analogous to Println,
// and records the text in the error log. For tests, the text will be printed only if
// the test fails or the -test.v flag is set. For benchmarks, the text is always
// printed to avoid having performance depend on the value of the -test.v flag.
func (p *T) Log(args ...any) {
log.Println(args...)
}

// Logf formats its arguments according to the format, analogous to Printf, and
// records the text in the error log. A final newline is added if not provided. For
// tests, the text will be printed only if the test fails or the -test.v flag is
// set. For benchmarks, the text is always printed to avoid having performance
// depend on the value of the -test.v flag.
func (p *T) Logf(format string, args ...any) {
log.Printf(format, args...)
}

// Errorln is equivalent to Log followed by Fail.
func (p *T) Errorln(args ...any) {
log.Println(args...)
p.Fail()
}

// Errorf is equivalent to Logf followed by Fail.
func (p *T) Errorf(format string, args ...any) {
log.Printf(format, args...)
p.Fail()
}

// Fatal is equivalent to Log followed by FailNow.
func (p *T) Fatal(args ...any) {
log.Println(args...)
p.FailNow()
}

// Fatalf is equivalent to Logf followed by FailNow.
func (p *T) Fatalf(format string, args ...any) {
log.Printf(format, args...)
p.FailNow()
}

// Skip is equivalent to Log followed by SkipNow.
func (p *T) Skip(args ...any) {
log.Println(args...)
p.SkipNow()
}

// Skipf is equivalent to Logf followed by SkipNow.
func (p *T) Skipf(format string, args ...any) {
log.Printf(format, args...)
p.SkipNow()
}

// SkipNow marks the test as having been skipped and stops its execution
// by calling runtime.Goexit.
// If a test fails (see Error, Errorf, Fail) and is then skipped,
// it is still considered to have failed.
// Execution will continue at the next test or benchmark. See also FailNow.
// SkipNow must be called from the goroutine running the test, not from
// other goroutines created during the test. Calling SkipNow does not stop
// those other goroutines.
func (p *T) SkipNow() {
p.skipped = true
runtime.Goexit()
}

// Skipped reports whether the test was skipped.
func (p *T) Skipped() bool {
return p.skipped
}

// Helper marks the calling function as a test helper function.
// When printing file and line information, that function will be skipped.
// Helper may be called simultaneously from multiple goroutines.
func (p *T) Helper() {
}

// Cleanup registers a function to be called when the test (or subtest) and all its
// subtests complete. Cleanup functions will be called in last added,
// first called order.
func (p *T) Cleanup(f func()) {
// TODO:
}

// TempDir returns a temporary directory for the test to use.
// The directory is automatically removed by Cleanup when the test and
// all its subtests complete.
// Each subsequent call to t.TempDir returns a unique directory;
// if the directory creation fails, TempDir terminates the test by calling Fatal.
func (p *T) TempDir() string {
panic("todo")
}

// Run runs f as a subtest of t called name.
//
// Run may be called simultaneously from multiple goroutines, but all such calls
// must return before the outer test function for t returns.
func (p *T) Run(name string, f func()) bool {
p.name = name
f()
return true
}

// Deadline reports the time at which the test binary will have
// exceeded the timeout specified by the -timeout flag.
//
// The ok result is false if the -timeout flag indicates “no timeout” (0).
func (p *T) Deadline() (deadline time.Time, ok bool) {
panic("todo")
}
Loading

0 comments on commit f2bd75e

Please sign in to comment.