Commit 98249b24 authored by Kirill Smelkov's avatar Kirill Smelkov

myname -> my

This causes the following changes on client side:

	myname.Func	-> my.FuncName
	myname.Pkg	-> my.PkgName

Reason for the change is that we are going to introduce my.File and
my.Line which would not fit into myname package naming.
parent a092b308
...@@ -22,7 +22,7 @@ import ( ...@@ -22,7 +22,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"lab.nexedi.com/kirr/go123/myname" "lab.nexedi.com/kirr/go123/my"
"lab.nexedi.com/kirr/go123/xruntime" "lab.nexedi.com/kirr/go123/xruntime"
) )
...@@ -147,7 +147,7 @@ var ( ...@@ -147,7 +147,7 @@ var (
) )
func init() { func init() {
_errorpkgname = myname.Pkg() _errorpkgname = my.PkgName()
_errorpkgdot = _errorpkgname + "." _errorpkgdot = _errorpkgname + "."
_errorraise = _errorpkgname + ".Raise" _errorraise = _errorpkgname + ".Raise"
} }
...@@ -187,7 +187,7 @@ func Addcallingcontext(topfunc string, e *Error) *Error { ...@@ -187,7 +187,7 @@ func Addcallingcontext(topfunc string, e *Error) *Error {
// the error, if non-nil, will be returned with added calling context - see // the error, if non-nil, will be returned with added calling context - see
// Addcallingcontext for details. // Addcallingcontext for details.
func Runx(xf func()) (err error) { func Runx(xf func()) (err error) {
here := myname.Func() here := my.FuncName()
defer Catch(func(e *Error) { defer Catch(func(e *Error) {
err = Addcallingcontext(here, e) err = Addcallingcontext(here, e)
}) })
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
"runtime" "runtime"
"testing" "testing"
"lab.nexedi.com/kirr/go123/myname" "lab.nexedi.com/kirr/go123/my"
) )
func do_raise1() { func do_raise1() {
...@@ -138,7 +138,7 @@ func TestErrAddCallingContext(t *testing.T) { ...@@ -138,7 +138,7 @@ func TestErrAddCallingContext(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
func() { func() {
myfunc := myname.Func() myfunc := my.FuncName()
defer Catch(func(e *Error) { defer Catch(func(e *Error) {
e = Addcallingcontext(myfunc, e) e = Addcallingcontext(myfunc, e)
msg := e.Error() msg := e.Error()
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
// //
// See COPYING file for full licensing terms. // See COPYING file for full licensing terms.
// Package myname provides easy way to determine current function's name and package // Package my provides easy way to determine current function's name and other context
package myname package my
import ( import (
"fmt" "fmt"
...@@ -34,15 +34,15 @@ func _myfuncname(nskip int) string { ...@@ -34,15 +34,15 @@ func _myfuncname(nskip int) string {
return f.Name() return f.Name()
} }
// get name of currently running function (caller of Func()) // FuncName returns name of currently running function (caller of FuncName())
// name is fully qualified package/name.function(.x) // name is fully qualified package/name.function(.x)
func Func() string { func FuncName() string {
return _myfuncname(3) return _myfuncname(3)
} }
// get name of currently running function's package // PkgName returns name of currently running function's package
// package is fully qualified package/name // package is fully qualified package/name
func Pkg() string { func PkgName() string {
myfunc := _myfuncname(3) myfunc := _myfuncname(3)
if myfunc == "" { if myfunc == "" {
return "" return ""
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
// //
// See COPYING file for full licensing terms. // See COPYING file for full licensing terms.
package myname package my
import ( import (
"strings" "strings"
...@@ -23,11 +23,11 @@ import ( ...@@ -23,11 +23,11 @@ import (
) )
func TestMyFuncName(t *testing.T) { func TestMyFuncName(t *testing.T) {
myfunc := Func() myfunc := FuncName()
// go test changes full package name (putting filesystem of the tree into ti) // go test changes full package name (putting filesystem of the tree into it)
// thus we check only for suffix // thus we check only for suffix
wantsuffix := ".TestMyFuncName" wantsuffix := ".TestMyFuncName"
if !strings.HasSuffix(myfunc, wantsuffix) { if !strings.HasSuffix(myfunc, wantsuffix) {
t.Errorf("myname.Func() -> %v ; want *%v", myfunc, wantsuffix) t.Errorf("my.FuncName() -> %v ; want *%v", myfunc, wantsuffix)
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment