repo stringlengths 6 47 | file_url stringlengths 77 269 | file_path stringlengths 5 186 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-07 08:35:43 2026-01-07 08:55:24 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/transaction.go | callbacks/transaction.go | package callbacks
import (
"gorm.io/gorm"
)
func BeginTransaction(db *gorm.DB) {
if !db.Config.SkipDefaultTransaction && db.Error == nil {
if tx := db.Begin(); tx.Error == nil {
db.Statement.ConnPool = tx.Statement.ConnPool
db.InstanceSet("gorm:started_transaction", true)
} else if tx.Error == gorm.ErrInv... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/interfaces.go | callbacks/interfaces.go | package callbacks
import "gorm.io/gorm"
type BeforeCreateInterface interface {
BeforeCreate(*gorm.DB) error
}
type AfterCreateInterface interface {
AfterCreate(*gorm.DB) error
}
type BeforeUpdateInterface interface {
BeforeUpdate(*gorm.DB) error
}
type AfterUpdateInterface interface {
AfterUpdate(*gorm.DB) err... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/delete.go | callbacks/delete.go | package callbacks
import (
"reflect"
"strings"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils"
)
func BeforeDelete(db *gorm.DB) {
if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && db.Statement.Schema.BeforeDelete {
callMethod(db, func(value interf... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/create_test.go | callbacks/create_test.go | package callbacks
import (
"reflect"
"sync"
"testing"
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
)
var schemaCache = &sync.Map{}
func TestConvertToCreateValues_DestType_Slice(t *testing.T) {
type user struct {
ID int `gorm:"primaryKey"`
Name string
Email string `gorm:"defaul... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/helper_test.go | callbacks/helper_test.go | package callbacks
import (
"reflect"
"testing"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
func TestLoadOrStoreVisitMap(t *testing.T) {
var vm visitMap
var loaded bool
type testM struct {
Name string
}
t1 := testM{Name: "t1"}
t2 := testM{Name: "t2"}
t3 := testM{Name: "t3"}
vm = make(visitMap)
if loaded =... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/associations.go | callbacks/associations.go | package callbacks
import (
"reflect"
"strings"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils"
)
func SaveBeforeAssociations(create bool) func(db *gorm.DB) {
return func(db *gorm.DB) {
if db.Error == nil && db.Statement.Schema != nil {
selectColumns, restricted := db.State... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/preload.go | callbacks/preload.go | package callbacks
import (
"fmt"
"reflect"
"sort"
"strings"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils"
)
// parsePreloadMap extracts nested preloads. e.g.
//
// // schema has a "k0" relation and a "k7.k8" embedded relation
// parsePreloadMap(schema, map[string][]interface... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/query.go | callbacks/query.go | package callbacks
import (
"fmt"
"reflect"
"strings"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils"
)
func Query(db *gorm.DB) {
if db.Error == nil {
BuildQuerySQL(db)
if !db.DryRun && db.Error == nil {
rows, err := db.Statement.ConnPool.QueryContext(db.Statement.Conte... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/raw.go | callbacks/raw.go | package callbacks
import (
"gorm.io/gorm"
)
func RawExec(db *gorm.DB) {
if db.Error == nil && !db.DryRun {
result, err := db.Statement.ConnPool.ExecContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
if err != nil {
db.AddError(err)
return
}
db.RowsAffected, _ = result.Rows... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/callmethod.go | callbacks/callmethod.go | package callbacks
import (
"reflect"
"gorm.io/gorm"
)
func callMethod(db *gorm.DB, fc func(value interface{}, tx *gorm.DB) bool) {
tx := db.Session(&gorm.Session{NewDB: true})
if called := fc(db.Statement.ReflectValue.Interface(), tx); !called {
switch db.Statement.ReflectValue.Kind() {
case reflect.Slice, r... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/callbacks.go | callbacks/callbacks.go | package callbacks
import (
"gorm.io/gorm"
)
var (
createClauses = []string{"INSERT", "VALUES", "ON CONFLICT"}
queryClauses = []string{"SELECT", "FROM", "WHERE", "GROUP BY", "ORDER BY", "LIMIT", "FOR"}
updateClauses = []string{"UPDATE", "SET", "WHERE"}
deleteClauses = []string{"DELETE", "FROM", "WHERE"}
)
type ... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/update.go | callbacks/update.go | package callbacks
import (
"reflect"
"sort"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils"
)
func SetupUpdateReflectValue(db *gorm.DB) {
if db.Error == nil && db.Statement.Schema != nil {
if !db.Statement.ReflectValue.CanAddr() || db.Statement.Model != db.Statement.Dest {
... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/callbacks/row.go | callbacks/row.go | package callbacks
import (
"gorm.io/gorm"
)
func RowQuery(db *gorm.DB) {
if db.Error == nil {
BuildQuerySQL(db)
if db.DryRun || db.Error != nil {
return
}
if isRows, ok := db.Get("rows"); ok && isRows.(bool) {
db.Statement.Settings.Delete("rows")
db.Statement.Dest, db.Error = db.Statement.ConnPool... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/internal/lru/lru.go | internal/lru/lru.go | package lru
// golang -lru
// https://github.com/hashicorp/golang-lru
import (
"sync"
"time"
)
// EvictCallback is used to get a callback when a cache entry is evicted
type EvictCallback[K comparable, V any] func(key K, value V)
// LRU implements a thread-safe LRU with expirable entries.
type LRU[K comparable, V a... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/internal/stmt_store/stmt_store.go | internal/stmt_store/stmt_store.go | package stmt_store
import (
"context"
"database/sql"
"math"
"sync"
"time"
"gorm.io/gorm/internal/lru"
)
type Stmt struct {
*sql.Stmt
Transaction bool
prepared chan struct{}
prepareErr error
}
func (stmt *Stmt) Error() error {
return stmt.prepareErr
}
func (stmt *Stmt) Close() error {
<-stmt.prepare... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/constraint_test.go | schema/constraint_test.go | package schema_test
import (
"reflect"
"sync"
"testing"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils/tests"
)
type UserCheck struct {
Name string `gorm:"check:name_checker,name <> 'jinzhu'"`
Name2 string `gorm:"check:name <> 'jinzhu'"`
Name3 string `gorm:"check:,name <> 'jinzhu'"`
}
func TestParseCheck(t *tes... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/index.go | schema/index.go | package schema
import (
"fmt"
"sort"
"strconv"
"strings"
)
type Index struct {
Name string
Class string // UNIQUE | FULLTEXT | SPATIAL
Type string // btree, hash, gist, spgist, gin, and brin
Where string
Comment string
Option string // WITH PARSER parser_name
Fields []IndexOption // Note... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/schema_helper_test.go | schema/schema_helper_test.go | package schema_test
import (
"context"
"fmt"
"reflect"
"strings"
"testing"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils/tests"
)
func checkSchema(t *testing.T, s *schema.Schema, v *schema.Schema, primaryFields []string) {
t.Run("CheckSchema/"+s.Name, func(t *testing.T) {
tests.AssertObjEqual(t, s, v, "Name", ... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/naming.go | schema/naming.go | package schema
import (
"crypto/sha1"
"encoding/hex"
"regexp"
"strings"
"unicode/utf8"
"github.com/jinzhu/inflection"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
// Namer namer interface
type Namer interface {
TableName(table string) string
SchemaName(table string) string
ColumnName(table, co... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/interfaces.go | schema/interfaces.go | package schema
import (
"gorm.io/gorm/clause"
)
// ConstraintInterface database constraint interface
type ConstraintInterface interface {
GetName() string
Build() (sql string, vars []interface{})
}
// GormDataTypeInterface gorm data type interface
type GormDataTypeInterface interface {
GormDataType() string
}
/... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/utils.go | schema/utils.go | package schema
import (
"context"
"fmt"
"reflect"
"regexp"
"strings"
"gorm.io/gorm/clause"
"gorm.io/gorm/utils"
)
var embeddedCacheKey = "embedded_cache_store"
func ParseTagSetting(str string, sep string) map[string]string {
settings := map[string]string{}
names := strings.Split(str, sep)
var parsedNames... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/field_test.go | schema/field_test.go | package schema_test
import (
"context"
"database/sql"
"reflect"
"sync"
"testing"
"time"
"gorm.io/gorm"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils/tests"
)
func TestFieldValuerAndSetter(t *testing.T) {
var (
userSchema, _ = schema.Parse(&tests.User{}, &sync.Map{}, schema.NamingStrategy{})
user =... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/naming_test.go | schema/naming_test.go | package schema
import (
"strings"
"testing"
)
func TestToDBName(t *testing.T) {
maps := map[string]string{
"": "",
"x": "x",
"X": "x",
"userRestrictions": "user_restrictions",
"ThisIsATest": "this_is_a_test",
... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/index_test.go | schema/index_test.go | package schema_test
import (
"sync"
"testing"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils/tests"
)
type UserIndex struct {
Name string `gorm:"index"`
Name2 string `gorm:"index:idx_name,unique"`
Name3 string `gorm:"index:,sort:desc,collate:utf8,type:btree,length:10,where:name3 != 'jinzhu'"`... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/relationship.go | schema/relationship.go | package schema
import (
"context"
"fmt"
"reflect"
"strings"
"sync"
"github.com/jinzhu/inflection"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"gorm.io/gorm/clause"
)
// RelationshipType relationship type
type RelationshipType string
const (
HasOne RelationshipType = "has_one" // HasOne... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/utils_test.go | schema/utils_test.go | package schema
import (
"reflect"
"testing"
)
func TestRemoveSettingFromTag(t *testing.T) {
tags := map[string]string{
`gorm:"before:value;column:db;after:value" other:"before:value;column:db;after:value"`: `gorm:"before:value;after:value" other:"before:value;column:db;after:value"`,
`gorm:"before:value;colum... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/serializer.go | schema/serializer.go | package schema
import (
"bytes"
"context"
"database/sql"
"database/sql/driver"
"encoding/gob"
"encoding/json"
"fmt"
"math"
"reflect"
"strings"
"sync"
"time"
)
var serializerMap = sync.Map{}
// RegisterSerializer register serializer
func RegisterSerializer(name string, serializer SerializerInterface) {
s... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/field.go | schema/field.go | package schema
import (
"context"
"database/sql"
"database/sql/driver"
"fmt"
"reflect"
"strconv"
"strings"
"sync"
"time"
"github.com/jinzhu/now"
"gorm.io/gorm/clause"
"gorm.io/gorm/utils"
)
// special types' reflect type
var (
TimeReflectType = reflect.TypeOf(time.Time{})
TimePtrReflectType = reflec... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | true |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/pool.go | schema/pool.go | package schema
import (
"reflect"
"sync"
)
// sync pools
var (
normalPool sync.Map
poolInitializer = func(reflectType reflect.Type) FieldNewValuePool {
v, _ := normalPool.LoadOrStore(reflectType, &sync.Pool{
New: func() interface{} {
return reflect.New(reflectType).Interface()
},
})
return v.... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/model_test.go | schema/model_test.go | package schema_test
import (
"database/sql"
"time"
"gorm.io/gorm"
"gorm.io/gorm/utils/tests"
)
type User struct {
*gorm.Model
Name *string
Age *uint
Birthday *time.Time
Account *tests.Account
Pets []*tests.Pet
Toys []*tests.Toy `gorm:"polymorphic:Owner"`
CompanyID *int
Company ... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/relationship_test.go | schema/relationship_test.go | package schema_test
import (
"sync"
"testing"
"time"
"gorm.io/gorm"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils/tests"
)
func checkStructRelation(t *testing.T, data interface{}, relations ...Relation) {
if s, err := schema.Parse(data, &sync.Map{}, schema.NamingStrategy{}); err != nil {
t.Errorf("Failed to par... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/callbacks_test.go | schema/callbacks_test.go | package schema_test
import (
"reflect"
"sync"
"testing"
"gorm.io/gorm"
"gorm.io/gorm/schema"
)
type UserWithCallback struct{}
func (UserWithCallback) BeforeSave(*gorm.DB) error {
return nil
}
func (UserWithCallback) AfterCreate(*gorm.DB) error {
return nil
}
func TestCallback(t *testing.T) {
user, err := ... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/constraint.go | schema/constraint.go | package schema
import (
"regexp"
"strings"
"gorm.io/gorm/clause"
)
// reg match english letters and midline
var regEnLetterAndMidline = regexp.MustCompile(`^[\w-]+$`)
type CheckConstraint struct {
Name string
Constraint string // length(phone) >= 10
*Field
}
func (chk *CheckConstraint) GetName() string... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/serializer_test.go | schema/serializer_test.go | package schema
import (
"context"
"math"
"reflect"
"testing"
"time"
)
func TestUnixSecondSerializer_Value(t *testing.T) {
var (
intValue = math.MaxInt64
int8Value = int8(math.MaxInt8)
int16Value = int16(math.MaxInt16)
int32Value = int32(math.MaxInt32)
int64Value = int64(math.MaxInt64... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/schema_test.go | schema/schema_test.go | package schema_test
import (
"strings"
"sync"
"testing"
"gorm.io/gorm"
"gorm.io/gorm/schema"
"gorm.io/gorm/utils/tests"
)
func TestParseSchema(t *testing.T) {
user, err := schema.Parse(&tests.User{}, &sync.Map{}, schema.NamingStrategy{})
if err != nil {
t.Fatalf("failed to parse user, got error %v", err)
... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
go-gorm/gorm | https://github.com/go-gorm/gorm/blob/0d9141bad9772c6047ecfdb2819d8a52d27ceb65/schema/schema.go | schema/schema.go | package schema
import (
"context"
"errors"
"fmt"
"go/ast"
"path"
"reflect"
"strings"
"sync"
"gorm.io/gorm/clause"
"gorm.io/gorm/logger"
)
type callbackType string
const (
callbackTypeBeforeCreate callbackType = "BeforeCreate"
callbackTypeBeforeUpdate callbackType = "BeforeUpdate"
callbackTypeAfterCreat... | go | MIT | 0d9141bad9772c6047ecfdb2819d8a52d27ceb65 | 2026-01-07T08:35:52.485253Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/api_impl_test.go | pkg/api/api_impl_test.go | package api
import (
"fmt"
"testing"
"github.com/evanw/esbuild/internal/test"
)
func TestStripDirPrefix(t *testing.T) {
expectSuccess := func(path string, prefix string, allowedSlashes string, expected string) {
t.Helper()
t.Run(fmt.Sprintf("path=%s prefix=%s slashes=%s", path, prefix, allowedSlashes), func(... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/api.go | pkg/api/api.go | // This API exposes esbuild's two main operations: building and transforming.
// It's intended for integrating esbuild into other tools as a library.
//
// If you are just trying to run esbuild from Go without the overhead of
// creating a child process, there is also an API for the command-line
// interface itself: ht... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/api_test.go | pkg/api/api_test.go | package api_test
import (
"testing"
"github.com/evanw/esbuild/internal/test"
"github.com/evanw/esbuild/pkg/api"
)
func TestFormatMessages(t *testing.T) {
check := func(name string, opts api.FormatMessagesOptions, msg api.Message, expected string) {
t.Helper()
t.Run(name, func(t *testing.T) {
test.AssertEq... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/serve_other.go | pkg/api/serve_other.go | //go:build !js || !wasm
// +build !js !wasm
package api
// This file implements the "Serve()" function in esbuild's public API. It
// provides a basic web server that can serve a directory tree over HTTP. When
// a directory is visited the "index.html" will be served if present, otherwise
// esbuild will automaticall... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/api_js_table.go | pkg/api/api_js_table.go | // This file was automatically generated by "js_table.ts"
package api
import "github.com/evanw/esbuild/internal/compat"
type EngineName uint8
const (
EngineChrome EngineName = iota
EngineDeno
EngineEdge
EngineFirefox
EngineHermes
EngineIE
EngineIOS
EngineNode
EngineOpera
EngineRhino
EngineSafari
)
func ... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/serve_wasm.go | pkg/api/serve_wasm.go | //go:build js && wasm
// +build js,wasm
package api
import "fmt"
// Remove the serve API in the WebAssembly build. This removes 2.7mb of stuff.
func (*internalContext) Serve(ServeOptions) (ServeResult, error) {
return ServeResult{}, fmt.Errorf("The \"serve\" API is not supported when using WebAssembly")
}
type ap... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/watcher.go | pkg/api/watcher.go | package api
// This file implements a polling file watcher for esbuild (i.e. it detects
// when files are changed by repeatedly checking their contents). Polling is
// used instead of more efficient platform-specific file system APIs because:
//
// * Go's standard library doesn't have built-in APIs for file watching... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/favicon.go | pkg/api/favicon.go | package api
// This is the "favicon.ico" file used by esbuild's built-in development server
var favicon_ico_gz = []byte{
0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x63, 0x60, 0x60, 0x64, 0x60, 0x62,
0x10, 0x10, 0x60, 0x00, 0xD2, 0x0A, 0x0C, 0x19, 0x2C, 0x0C, 0x0C, 0x6A, 0x0C, 0x0C, 0x0C, 0x0A,
0x0... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/api/api_impl.go | pkg/api/api_impl.go | package api
// This file implements most of the API. This includes the "Build", "Transform",
// "FormatMessages", and "AnalyzeMetafile" functions.
import (
"bytes"
"encoding/base64"
"encoding/binary"
"errors"
"fmt"
"io/ioutil"
"math"
"os"
"path"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"time"
"unico... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/cli/cli_js_table.go | pkg/cli/cli_js_table.go | // This file was automatically generated by "js_table.ts"
package cli
import "github.com/evanw/esbuild/pkg/api"
var validEngines = map[string]api.EngineName{
"chrome": api.EngineChrome,
"deno": api.EngineDeno,
"edge": api.EngineEdge,
"firefox": api.EngineFirefox,
"hermes": api.EngineHermes,
"ie": ... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/cli/cli_impl.go | pkg/cli/cli_impl.go | package cli
// This file implements the public CLI. It's deliberately implemented using
// esbuild's public "Build", "Transform", and "AnalyzeMetafile" APIs instead of
// using internal APIs so that any tests that cover the CLI also implicitly
// cover the public API as well.
import (
"fmt"
"io/ioutil"
"net"
"os"... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/cli/cli.go | pkg/cli/cli.go | // This API exposes the command-line interface for esbuild. It can be used to
// run esbuild from Go without the overhead of creating a child process.
//
// Example usage:
//
// package main
//
// import (
// "os"
//
// "github.com/evanw/esbuild/pkg/cli"
// )
//
// func main() {
// os.Exit(cli.Run(os.Args[1... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/pkg/cli/mangle_cache.go | pkg/cli/mangle_cache.go | package cli
// The mangle cache is a JSON file that remembers esbuild's property renaming
// decisions. It's a flat map where the keys are strings and the values are
// either strings or the boolean value "false". This is the case both in JSON
// and in Go (so the "interface{}" values are also either strings or "false... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/cmd/esbuild/service.go | cmd/esbuild/service.go | // This implements a simple long-running service over stdin/stdout. Each
// incoming request is an array of strings, and each outgoing response is a map
// of strings to byte slices. All values are length-prefixed using 32-bit
// little endian integers.
package main
import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/cmd/esbuild/stdio_protocol.go | cmd/esbuild/stdio_protocol.go | // The JavaScript API communicates with the Go child process over stdin/stdout
// using this protocol. It's a very simple binary protocol that uses primitives
// and nested arrays and maps. It's basically JSON with UTF-8 encoding and an
// additional byte array primitive. You must send a response after receiving a
// r... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/cmd/esbuild/main_other.go | cmd/esbuild/main_other.go | //go:build !js || !wasm
// +build !js !wasm
package main
import (
"fmt"
"os"
"runtime/pprof"
"runtime/trace"
"github.com/evanw/esbuild/internal/logger"
)
func createTraceFile(osArgs []string, traceFile string) func() {
f, err := os.Create(traceFile)
if err != nil {
logger.PrintErrorToStderr(osArgs, fmt.Spr... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/cmd/esbuild/main_wasm.go | cmd/esbuild/main_wasm.go | //go:build js && wasm
// +build js,wasm
package main
import (
"github.com/evanw/esbuild/internal/logger"
)
// Remove this code from the WebAssembly binary to reduce size. This only removes 0.4mb of stuff.
func createTraceFile(osArgs []string, traceFile string) func() {
logger.PrintErrorToStderr(osArgs, "The \"--t... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/cmd/esbuild/version.go | cmd/esbuild/version.go | package main
const esbuildVersion = "0.27.2"
| go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/cmd/esbuild/main.go | cmd/esbuild/main.go | package main
import (
"fmt"
"io"
"os"
"runtime/debug"
"strings"
"time"
"github.com/evanw/esbuild/internal/api_helpers"
"github.com/evanw/esbuild/internal/logger"
"github.com/evanw/esbuild/pkg/cli"
)
var helpText = func(colors logger.Colors) string {
// Read "NO_COLOR" from the environment. This is a conven... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_glob_test.go | internal/bundler_tests/bundler_glob_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var glob_suite = suite{
name: "glob",
}
func TestGlobBasicNoBundle(t *testing.T) {
glob_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
const ab = Math.random() < 0.5 ? 'a.js' : 'b.js'
con... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_importstar_ts_test.go | internal/bundler_tests/bundler_importstar_ts_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var importstar_ts_suite = suite{
name: "importstar_ts",
}
func TestTSImportStarUnused(t *testing.T) {
importstar_ts_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.ts": `
import * as ns from './foo'
... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_tsconfig_test.go | internal/bundler_tests/bundler_tsconfig_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var tsconfig_suite = suite{
name: "tsconfig",
}
func TestTsconfigPaths(t *testing.T) {
tsconfig_suite.expectBundled(t, bundled{
files: map[string]string{
"/Users/user/project/entry.ts": `
import baseurl_dot from './ba... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_yarnpnp_test.go | internal/bundler_tests/bundler_yarnpnp_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var yarnpnp_suite = suite{
name: "yarnpnp",
}
// https://github.com/evanw/esbuild/issues/3698
func TestTsconfigPackageJsonExportsYarnPnP(t *testing.T) {
yarnpnp_suite.expectBundled(t, bundled{
files: map[string]string{
"/... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_loader_test.go | internal/bundler_tests/bundler_loader_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/bundler"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
)
var loader_suite = suite{
name: "loader",
}
func TestLoaderFile(t *testing.T) {
loader_suite.expectBundled(t, bundled{
files: map[strin... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_ts_test.go | internal/bundler_tests/bundler_ts_test.go | package bundler_tests
import (
"regexp"
"testing"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
)
var ts_suite = suite{
name: "ts",
}
func TestTSDeclareConst(t *testing.T) {
ts_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.ts": `
declare con... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_importstar_test.go | internal/bundler_tests/bundler_importstar_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var importstar_suite = suite{
name: "importstar",
}
func TestImportStarUnused(t *testing.T) {
importstar_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
import * as ns from './foo'
let foo... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_css_test.go | internal/bundler_tests/bundler_css_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
)
var css_suite = suite{
name: "css",
}
func TestCSSEntryPoint(t *testing.T) {
css_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.css": `
body {
backgr... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_splitting_test.go | internal/bundler_tests/bundler_splitting_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var splitting_suite = suite{
name: "splitting",
}
func TestSplittingSharedES6IntoES6(t *testing.T) {
splitting_suite.expectBundled(t, bundled{
files: map[string]string{
"/a.js": `
import {foo} from "./shared.js"
c... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_lower_test.go | internal/bundler_tests/bundler_lower_test.go | package bundler_tests
// This file contains tests for "lowering" syntax, which means converting it to
// older JavaScript. For example, "a ** b" becomes a call to "Math.pow(a, b)"
// when lowered. Which syntax is lowered is determined by the language target.
import (
"testing"
"github.com/evanw/esbuild/internal/co... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_test.go | internal/bundler_tests/bundler_test.go | package bundler_tests
// Bundling test results are stored in snapshot files, located in the
// "snapshots" directory. This allows test results to be updated easily without
// manually rewriting all of the expected values. To update the tests run
// "UPDATE_SNAPSHOTS=1 make test" and commit the updated values. Make sur... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_default_test.go | internal/bundler_tests/bundler_default_test.go | package bundler_tests
import (
"regexp"
"strings"
"testing"
"github.com/evanw/esbuild/internal/bundler"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
"github.com/evanw/esbuild/internal/helpers"
"github.com/evanw/esbuild/internal/js_ast"
"github.com/evanw/esbuild/intern... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_packagejson_test.go | internal/bundler_tests/bundler_packagejson_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var packagejson_suite = suite{
name: "packagejson",
}
func TestPackageJsonMain(t *testing.T) {
packagejson_suite.expectBundled(t, bundled{
files: map[string]string{
"/Users/user/project/src/entry.js": `
import fn from... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_dce_test.go | internal/bundler_tests/bundler_dce_test.go | package bundler_tests
import (
"regexp"
"testing"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
)
var dce_suite = suite{
name: "dce",
}
func TestPackageJsonSideEffectsFalseKeepNamedImportES6(t *testing.T) {
dce_suite.expectBundled(t, bundled{
files: map[string]string{... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/bundler_tests/bundler_importphase_test.go | internal/bundler_tests/bundler_importphase_test.go | package bundler_tests
import (
"testing"
"github.com/evanw/esbuild/internal/config"
)
var importphase_suite = suite{
name: "importphase",
}
func TestImportDeferExternalESM(t *testing.T) {
importphase_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
import defer * as foo0 from '.... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/js_printer/js_printer.go | internal/js_printer/js_printer.go | package js_printer
import (
"bytes"
"fmt"
"math"
"math/big"
"strconv"
"strings"
"unicode/utf8"
"github.com/evanw/esbuild/internal/ast"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
"github.com/evanw/esbuild/internal/helpers"
"github.com/evanw/esbuild/internal/js_ast... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/js_printer/js_printer_test.go | internal/js_printer/js_printer_test.go | package js_printer
import (
"strings"
"testing"
"github.com/evanw/esbuild/internal/ast"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
"github.com/evanw/esbuild/internal/js_parser"
"github.com/evanw/esbuild/internal/logger"
"github.com/evanw/esbuild/internal/renamer"
"g... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/compat/compat.go | internal/compat/compat.go | package compat
import (
"strconv"
"strings"
"github.com/evanw/esbuild/internal/ast"
)
type v struct {
major uint16
minor uint8
patch uint8
}
type Semver struct {
// "1.2.3-alpha" => { Parts: {1, 2, 3}, PreRelease: "-alpha" }
Parts []int
PreRelease string
}
func (v Semver) String() string {
b := stri... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/compat/js_table.go | internal/compat/js_table.go | // This file was automatically generated by "js_table.ts"
package compat
type Engine uint8
const (
Chrome Engine = iota
Deno
Edge
ES
Firefox
Hermes
IE
IOS
Node
Opera
Rhino
Safari
)
func (e Engine) String() string {
switch e {
case Chrome:
return "chrome"
case Deno:
return "deno"
case Edge:
ret... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/compat/compat_test.go | internal/compat/compat_test.go | package compat
import (
"fmt"
"testing"
"github.com/evanw/esbuild/internal/test"
)
func TestCompareVersions(t *testing.T) {
t.Helper()
check := func(a v, b Semver, expected rune) {
t.Helper()
at := fmt.Sprintf("%d.%d.%d", a.major, a.minor, a.patch)
bt := b.String()
t.Run(fmt.Sprintf("%q ? %q", at, bt... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/compat/css_table.go | internal/compat/css_table.go | // This file was automatically generated by "css_table.ts"
package compat
import (
"github.com/evanw/esbuild/internal/css_ast"
)
type CSSFeature uint16
const (
ColorFunctions CSSFeature = 1 << iota
GradientDoublePosition
GradientInterpolation
GradientMidpoints
HWB
HexRGBA
InlineStyle
InsetProperty
IsPseud... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/logger/logger_linux.go | internal/logger/logger_linux.go | //go:build linux
// +build linux
package logger
import (
"os"
"golang.org/x/sys/unix"
)
const SupportsColorEscapes = true
func GetTerminalInfo(file *os.File) (info TerminalInfo) {
fd := file.Fd()
// Is this file descriptor a terminal?
if _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS); err == nil {
in... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/logger/msg_ids.go | internal/logger/msg_ids.go | package logger
// Most non-error log messages are given a message ID that can be used to set
// the log level for that message. Errors do not get a message ID because you
// cannot turn errors into non-errors (otherwise the build would incorrectly
// succeed). Some internal log messages do not get a message ID because... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/logger/logger_test.go | internal/logger/logger_test.go | package logger_test
import (
"testing"
"github.com/evanw/esbuild/internal/logger"
"github.com/evanw/esbuild/internal/test"
)
func TestMsgIDs(t *testing.T) {
for id := logger.MsgID_None; id <= logger.MsgID_END; id++ {
str := logger.MsgIDToString(id)
if str == "" {
continue
}
overrides := make(map[logg... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/logger/logger_other.go | internal/logger/logger_other.go | //go:build !darwin && !linux && !windows
// +build !darwin,!linux,!windows
package logger
import "os"
const SupportsColorEscapes = false
func GetTerminalInfo(*os.File) TerminalInfo {
return TerminalInfo{}
}
func writeStringWithColor(file *os.File, text string) {
file.WriteString(text)
}
| go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/logger/logger_windows.go | internal/logger/logger_windows.go | //go:build windows
// +build windows
package logger
import (
"os"
"strings"
"syscall"
"unsafe"
)
const SupportsColorEscapes = true
var kernel32 = syscall.NewLazyDLL("kernel32.dll")
var getConsoleMode = kernel32.NewProc("GetConsoleMode")
var setConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
v... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/logger/logger.go | internal/logger/logger.go | package logger
// Logging is either done to stderr (via "NewStderrLog") or to an in-memory
// array (via "NewDeferLog"). In-memory arrays are used to capture messages
// from parsing individual files because during incremental builds, log
// messages for a given file can be replayed from memory if the file ends up
// ... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | true |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/logger/logger_darwin.go | internal/logger/logger_darwin.go | //go:build darwin
// +build darwin
package logger
import (
"os"
"golang.org/x/sys/unix"
)
const SupportsColorEscapes = true
func GetTerminalInfo(file *os.File) (info TerminalInfo) {
fd := file.Fd()
// Is this file descriptor a terminal?
if _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA); err == nil {
... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/cache/cache_fs.go | internal/cache/cache_fs.go | package cache
import (
"sync"
"github.com/evanw/esbuild/internal/fs"
)
// This cache uses information from the "stat" syscall to try to avoid re-
// reading files from the file system during subsequent builds if the file
// hasn't changed. The assumption is reading the file metadata is faster than
// reading the f... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/cache/cache.go | internal/cache/cache.go | package cache
import (
"sync"
"github.com/evanw/esbuild/internal/logger"
"github.com/evanw/esbuild/internal/runtime"
)
// This is a cache of the parsed contents of a set of files. The idea is to be
// able to reuse the results of parsing between builds and make subsequent
// builds faster by avoiding redundant pa... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/cache/cache_ast.go | internal/cache/cache_ast.go | package cache
import (
"sync"
"github.com/evanw/esbuild/internal/css_ast"
"github.com/evanw/esbuild/internal/css_parser"
"github.com/evanw/esbuild/internal/js_ast"
"github.com/evanw/esbuild/internal/js_parser"
"github.com/evanw/esbuild/internal/logger"
)
// This cache intends to avoid unnecessarily re-parsing ... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/css_lexer/css_lexer_test.go | internal/css_lexer/css_lexer_test.go | package css_lexer
import (
"strings"
"testing"
"github.com/evanw/esbuild/internal/logger"
"github.com/evanw/esbuild/internal/test"
)
func lexToken(contents string) (T, string) {
log := logger.NewDeferLog(logger.DeferLogNoVerboseOrDebug, nil)
result := Tokenize(log, test.SourceForTest(contents), Options{})
if ... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/css_lexer/css_lexer.go | internal/css_lexer/css_lexer.go | package css_lexer
import (
"strings"
"unicode/utf8"
"github.com/evanw/esbuild/internal/logger"
)
// The lexer converts a source file to a stream of tokens. Unlike esbuild's
// JavaScript lexer, this CSS lexer runs to completion before the CSS parser
// begins, resulting in a single array of all tokens in the file... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/comment.go | internal/helpers/comment.go | package helpers
import (
"strings"
)
func EscapeClosingTag(text string, slashTag string) string {
if slashTag == "" {
return text
}
i := strings.Index(text, "</")
if i < 0 {
return text
}
var b strings.Builder
for {
b.WriteString(text[:i+1])
text = text[i+1:]
if len(text) >= len(slashTag) && strings... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/mime.go | internal/helpers/mime.go | package helpers
import "strings"
var builtinTypesLower = map[string]string{
// Text
".css": "text/css; charset=utf-8",
".htm": "text/html; charset=utf-8",
".html": "text/html; charset=utf-8",
".js": "text/javascript; charset=utf-8",
".json": "application/json; charset=utf-8",
".markdown... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/path.go | internal/helpers/path.go | package helpers
import (
"net/url"
"strings"
"github.com/evanw/esbuild/internal/fs"
)
func IsInsideNodeModules(path string) bool {
for {
// This is written in a platform-independent manner because it's run on
// user-specified paths which can be arbitrary non-file-system things. So
// for example Windows p... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/bitset.go | internal/helpers/bitset.go | package helpers
import "bytes"
type BitSet struct {
entries []byte
}
func NewBitSet(bitCount uint) BitSet {
return BitSet{make([]byte, (bitCount+7)/8)}
}
func (bs BitSet) HasBit(bit uint) bool {
return (bs.entries[bit/8] & (1 << (bit & 7))) != 0
}
func (bs BitSet) SetBit(bit uint) {
bs.entries[bit/8] |= 1 << (... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/timer.go | internal/helpers/timer.go | package helpers
import (
"fmt"
"strings"
"sync"
"time"
"github.com/evanw/esbuild/internal/logger"
)
type Timer struct {
data []timerData
mutex sync.Mutex
}
type timerData struct {
time time.Time
name string
isEnd bool
}
func (t *Timer) Begin(name string) {
if t != nil {
t.data = append(t.data, time... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/hash.go | internal/helpers/hash.go | package helpers
// From: http://boost.sourceforge.net/doc/html/boost/hash_combine.html
func HashCombine(seed uint32, hash uint32) uint32 {
return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2))
}
func HashCombineString(seed uint32, text string) uint32 {
seed = HashCombine(seed, uint32(len(text)))
for _, c :... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/quote.go | internal/helpers/quote.go | package helpers
import "unicode/utf8"
const hexChars = "0123456789ABCDEF"
const firstASCII = 0x20
const lastASCII = 0x7E
const firstHighSurrogate = 0xD800
const firstLowSurrogate = 0xDC00
const lastLowSurrogate = 0xDFFF
func canPrintWithoutEscape(c rune, asciiOnly bool) bool {
if c <= lastASCII {
return c >= firs... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/glob.go | internal/helpers/glob.go | package helpers
import "strings"
type GlobWildcard uint8
const (
GlobNone GlobWildcard = iota
GlobAllExceptSlash
GlobAllIncludingSlash
)
type GlobPart struct {
Prefix string
Wildcard GlobWildcard
}
// The returned array will always be at least one element. If there are no
// wildcards then it will be exactl... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/stack.go | internal/helpers/stack.go | package helpers
import (
"runtime/debug"
"strings"
)
func PrettyPrintedStack() string {
lines := strings.Split(strings.TrimSpace(string(debug.Stack())), "\n")
// Strip the first "goroutine" line
if len(lines) > 0 {
if first := lines[0]; strings.HasPrefix(first, "goroutine ") && strings.HasSuffix(first, ":") {... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/joiner.go | internal/helpers/joiner.go | package helpers
import (
"bytes"
"strings"
)
// This provides an efficient way to join lots of big string and byte slices
// together. It avoids the cost of repeatedly reallocating as the buffer grows
// by measuring exactly how big the buffer should be and then allocating once.
// This is a measurable speedup.
typ... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/strings.go | internal/helpers/strings.go | package helpers
import (
"fmt"
"strings"
)
func StringArraysEqual(a []string, b []string) bool {
if len(a) != len(b) {
return false
}
for i, x := range a {
if x != b[i] {
return false
}
}
return true
}
func StringArrayArraysEqual(a [][]string, b [][]string) bool {
if len(a) != len(b) {
return fals... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
evanw/esbuild | https://github.com/evanw/esbuild/blob/cd832972927f1f67b6d2cc895c06a8759c1cf309/internal/helpers/waitgroup.go | internal/helpers/waitgroup.go | package helpers
import "sync/atomic"
// Go's "sync.WaitGroup" is not thread-safe. Specifically it's not safe to call
// "Add" concurrently with "Wait", which is problematic because we have a case
// where we would like to do that.
//
// This is a simple alternative implementation of "sync.WaitGroup" that is
// thread... | go | MIT | cd832972927f1f67b6d2cc895c06a8759c1cf309 | 2026-01-07T08:35:49.242278Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.