diff --git a/Makefile b/Makefile index 3b4e26c..e1c8904 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -MODULE_NAME=python3 +MODULE_NAME=python VENDOR_DIR = vendor diff --git a/README.md b/README.md index 8aa1076..9d2f380 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Go high-level bindings for the CPython-3 C-API -[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/go-python3)](https://github.com/nhatthm/go-python3/releases/latest) -[![Build Status](https://github.com/nhatthm/go-python3/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/go-python3/actions/workflows/test.yaml) -[![codecov](https://codecov.io/gh/nhatthm/go-python3/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/go-python3) -[![Go Report Card](https://goreportcard.com/badge/go.nhat.io/python3)](https://goreportcard.com/report/go.nhat.io/python3) -[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/go.nhat.io/python3) +[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/go-python)](https://github.com/nhatthm/go-python/releases/latest) +[![Build Status](https://github.com/nhatthm/go-python/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/go-python/actions/workflows/test.yaml) +[![codecov](https://codecov.io/gh/nhatthm/go-python/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/go-python) +[![Go Report Card](https://goreportcard.com/badge/go.nhat.io/python)](https://goreportcard.com/report/go.nhat.io/python) +[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/go.nhat.io/python) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY) > [!IMPORTANT] @@ -24,69 +24,69 @@ Main goals: ## Install ```bash -go get go.nhat.io/python3 +go get go.nhat.io/python/v3 ``` ## Examples ```go -package python3_test +package main import ( - "fmt" + "fmt" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) -func ExampleVersion() { - sys := python3.MustImportModule("sys") - version := sys.GetAttr("version_info") +func main() { + sys := python3.MustImportModule("sys") + version := sys.GetAttr("version_info") - pyMajor := version.GetAttr("major") - defer pyMajor.DecRef() + pyMajor := version.GetAttr("major") + defer pyMajor.DecRef() - pyMinor := version.GetAttr("minor") - defer pyMinor.DecRef() + pyMinor := version.GetAttr("minor") + defer pyMinor.DecRef() - pyReleaseLevel := version.GetAttr("releaselevel") - defer pyReleaseLevel.DecRef() + pyReleaseLevel := version.GetAttr("releaselevel") + defer pyReleaseLevel.DecRef() - major := python3.AsInt(pyMajor) - minor := python3.AsInt(pyMinor) - releaseLevel := python3.AsString(pyReleaseLevel) + major := python3.AsInt(pyMajor) + minor := python3.AsInt(pyMinor) + releaseLevel := python3.AsString(pyReleaseLevel) - fmt.Println("major:", major) - fmt.Println("minor:", minor) - fmt.Println("release level:", releaseLevel) + fmt.Println("major:", major) + fmt.Println("minor:", minor) + fmt.Println("release level:", releaseLevel) - // Output: - // major: 3 - // minor: 11 - // release level: final + // Output: + // major: 3 + // minor: 11 + // release level: final } ``` ```go -package python3_test +package main import ( - "fmt" + "fmt" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) -func ExampleMath() { - math := python3.MustImportModule("math") +func main() { //nolint: govet + math := python3.MustImportModule("math") - pyResult := math.CallMethodArgs("sqrt", 4) - defer pyResult.DecRef() + pyResult := math.CallMethodArgs("sqrt", 4) + defer pyResult.DecRef() - result := python3.AsFloat64(pyResult) + result := python3.AsFloat64(pyResult) - fmt.Printf("sqrt(4) = %.2f\n", result) + fmt.Printf("sqrt(4) = %.2f\n", result) - // Output: - // sqrt(4) = 2.00 + // Output: + // sqrt(4) = 2.00 } ``` diff --git a/bool.go b/bool.go index 2b275a2..1b68d34 100644 --- a/bool.go +++ b/bool.go @@ -1,4 +1,4 @@ -package python3 +package python import "go.nhat.io/cpy3" diff --git a/bool_test.go b/bool_test.go index 73ed410..ca5f0a0 100644 --- a/bool_test.go +++ b/bool_test.go @@ -1,11 +1,11 @@ -package python3_test +package python_test import ( "testing" "github.com/stretchr/testify/assert" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestBool(t *testing.T) { diff --git a/doc.go b/doc.go index 9355462..8224f2b 100644 --- a/doc.go +++ b/doc.go @@ -1,2 +1,2 @@ -// Package python3 provides a high-level interface to the Python C API. -package python3 +// Package python provides a high-level interface to the Python C API. +package python diff --git a/error.go b/error.go index 3dabcfc..cd2f4a4 100644 --- a/error.go +++ b/error.go @@ -1,4 +1,4 @@ -package python3 +package python import ( "go.nhat.io/cpy3" diff --git a/examples/import-modules/main.go b/examples/import-modules/main.go index 49731c2..a164060 100644 --- a/examples/import-modules/main.go +++ b/examples/import-modules/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func main() { diff --git a/examples/math/main.go b/examples/math/main.go index 4362364..8234ca1 100644 --- a/examples/math/main.go +++ b/examples/math/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func main() { //nolint: govet diff --git a/float.go b/float.go index 59c4836..7e241e3 100644 --- a/float.go +++ b/float.go @@ -1,4 +1,4 @@ -package python3 +package python import "go.nhat.io/cpy3" diff --git a/float_test.go b/float_test.go index bf9df69..4669a5f 100644 --- a/float_test.go +++ b/float_test.go @@ -1,11 +1,11 @@ -package python3_test +package python_test import ( "testing" "github.com/stretchr/testify/assert" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestFloat64(t *testing.T) { diff --git a/go.mod b/go.mod index 9dd64e9..2c05a7a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module go.nhat.io/python3 +module go.nhat.io/python/v3 go 1.22 diff --git a/import.go b/import.go index 81a7014..edd0d0e 100644 --- a/import.go +++ b/import.go @@ -1,4 +1,4 @@ -package python3 +package python import ( "go.nhat.io/cpy3" diff --git a/import_test.go b/import_test.go index 6b58cdf..e016a0d 100644 --- a/import_test.go +++ b/import_test.go @@ -1,4 +1,4 @@ -package python3_test +package python_test import ( "runtime" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestMustImportModule(t *testing.T) { diff --git a/init.go b/init.go index 309f33b..c11b3fc 100644 --- a/init.go +++ b/init.go @@ -1,4 +1,4 @@ -package python3 +package python import ( "go.nhat.io/cpy3" diff --git a/init_test.go b/init_test.go index 48df4ec..a64fda3 100644 --- a/init_test.go +++ b/init_test.go @@ -1,10 +1,10 @@ -package python3_test +package python_test import ( "os" "testing" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) // TestMain is the entry point for the test suite. diff --git a/integer.go b/integer.go index 7dcdddd..cca66e4 100644 --- a/integer.go +++ b/integer.go @@ -1,4 +1,4 @@ -package python3 +package python import "go.nhat.io/cpy3" diff --git a/integer_test.go b/integer_test.go index bc20926..a23081d 100644 --- a/integer_test.go +++ b/integer_test.go @@ -1,11 +1,11 @@ -package python3_test +package python_test import ( "testing" "github.com/stretchr/testify/assert" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestInt(t *testing.T) { diff --git a/list.go b/list.go index 71a0560..5b5a880 100644 --- a/list.go +++ b/list.go @@ -1,4 +1,4 @@ -package python3 +package python import ( "reflect" diff --git a/list_test.go b/list_test.go index 15f0c50..a983203 100644 --- a/list_test.go +++ b/list_test.go @@ -1,4 +1,4 @@ -package python3_test +package python_test import ( "testing" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "go.nhat.io/cpy3" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestList_DecRefNil(t *testing.T) { diff --git a/marshal.go b/marshal.go index d99ebc1..8fad55c 100644 --- a/marshal.go +++ b/marshal.go @@ -1,4 +1,4 @@ -package python3 +package python import "C" import ( diff --git a/marshal_test.go b/marshal_test.go index e4fdbb7..e4e4c16 100644 --- a/marshal_test.go +++ b/marshal_test.go @@ -1,4 +1,4 @@ -package python3_test +package python_test import ( "reflect" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestMarshal(t *testing.T) { diff --git a/object.go b/object.go index 5744b8a..c43a152 100644 --- a/object.go +++ b/object.go @@ -1,4 +1,4 @@ -package python3 +package python import "go.nhat.io/cpy3" diff --git a/string.go b/string.go index 76b5ccf..93b7e37 100644 --- a/string.go +++ b/string.go @@ -1,4 +1,4 @@ -package python3 +package python import "go.nhat.io/cpy3" diff --git a/string_test.go b/string_test.go index 1077db7..33b8108 100644 --- a/string_test.go +++ b/string_test.go @@ -1,11 +1,11 @@ -package python3_test +package python_test import ( "testing" "github.com/stretchr/testify/assert" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestString(t *testing.T) { diff --git a/tuple.go b/tuple.go index 246f181..b63a545 100644 --- a/tuple.go +++ b/tuple.go @@ -1,4 +1,4 @@ -package python3 +package python import ( "reflect" diff --git a/tuple_test.go b/tuple_test.go index ed026ef..fc4fb45 100644 --- a/tuple_test.go +++ b/tuple_test.go @@ -1,4 +1,4 @@ -package python3_test +package python_test import ( "testing" @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "go.nhat.io/cpy3" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestTuple_DecRefNil(t *testing.T) { diff --git a/type.go b/type.go index 894d1c3..e6ccd6f 100644 --- a/type.go +++ b/type.go @@ -1,4 +1,4 @@ -package python3 +package python // TypeName returns the name of the type of the given object. func TypeName(o *Object) string { diff --git a/type_test.go b/type_test.go index 51a7763..ffcd92f 100644 --- a/type_test.go +++ b/type_test.go @@ -1,11 +1,11 @@ -package python3_test +package python_test import ( "testing" "github.com/stretchr/testify/assert" - "go.nhat.io/python3" + python3 "go.nhat.io/python/v3" ) func TestTypeName(t *testing.T) {