Initial commit: Go 1.23 release state

This commit is contained in:
Vorapol Rinsatitnon
2024-09-21 23:49:08 +10:00
commit 17cd57a668
13231 changed files with 3114330 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package aconfig
type Config struct {
name string
blah int
}

View File

@@ -0,0 +1,27 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bresource
type Resource[T any] struct {
name string
initializer Initializer[T]
cfg ResConfig
value T
}
func Should[T any](r *Resource[T], e error) bool {
return r.cfg.ShouldRetry(e)
}
type ResConfig struct {
ShouldRetry func(error) bool
TearDown func()
}
type Initializer[T any] func(*int) (T, error)
func New[T any](name string, f Initializer[T], cfg ResConfig) *Resource[T] {
return &Resource[T]{name: name, initializer: f, cfg: cfg}
}

View File

@@ -0,0 +1,37 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cmem
import (
"./aconfig"
"./bresource"
)
type MemT *int
var G int
type memResource struct {
x *int
}
func (m *memResource) initialize(*int) (res *int, err error) {
return nil, nil
}
func (m *memResource) teardown() {
}
func NewResource(cfg *aconfig.Config) *bresource.Resource[*int] {
res := &memResource{
x: &G,
}
return bresource.New("Mem", res.initialize, bresource.ResConfig{
// We always would want to retry the Memcache initialization.
ShouldRetry: func(error) bool { return true },
TearDown: res.teardown,
})
}

View File

@@ -0,0 +1,39 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dcache
import (
"./aconfig"
"./bresource"
"./cmem"
)
type Module struct {
cfg *aconfig.Config
err error
last any
}
//go:noinline
func TD() {
}
func (m *Module) Configure(x string) error {
if m.err != nil {
return m.err
}
res := cmem.NewResource(m.cfg)
m.last = res
return nil
}
func (m *Module) Blurb(x string, e error) bool {
res, ok := m.last.(*bresource.Resource[*int])
if !ok {
panic("bad")
}
return bresource.Should(res, e)
}

View File

@@ -0,0 +1,17 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"./dcache"
)
func main() {
var m dcache.Module
m.Configure("x")
m.Configure("y")
var e error
m.Blurb("x", e)
}