mirror of
https://github.com/golang/go
synced 2024-11-19 13:34:45 -07:00
remove unnecessary pkg. references
R=r DELTA=95 (0 added, 0 deleted, 95 changed) OCL=33012 CL=33012
This commit is contained in:
parent
7732f79daa
commit
0496040bd6
@ -8,7 +8,7 @@ import "container/vector"
|
|||||||
|
|
||||||
// IntVector is a specialization of Vector that hides the wrapping of Elements around ints.
|
// IntVector is a specialization of Vector that hides the wrapping of Elements around ints.
|
||||||
type IntVector struct {
|
type IntVector struct {
|
||||||
vector.Vector;
|
Vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import "container/vector"
|
|||||||
|
|
||||||
// StringVector is a specialization of Vector that hides the wrapping of Elements around strings.
|
// StringVector is a specialization of Vector that hides the wrapping of Elements around strings.
|
||||||
type StringVector struct {
|
type StringVector struct {
|
||||||
vector.Vector;
|
Vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,15 +11,15 @@ import "fmt"
|
|||||||
|
|
||||||
|
|
||||||
func TestZeroLen(t *testing.T) {
|
func TestZeroLen(t *testing.T) {
|
||||||
var a *vector.Vector;
|
var a *Vector;
|
||||||
if a.Len() != 0 { t.Errorf("A) expected 0, got %d", a.Len()); }
|
if a.Len() != 0 { t.Errorf("A) expected 0, got %d", a.Len()); }
|
||||||
a = vector.New(0);
|
a = New(0);
|
||||||
if a.Len() != 0 { t.Errorf("B) expected 0, got %d", a.Len()); }
|
if a.Len() != 0 { t.Errorf("B) expected 0, got %d", a.Len()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestInit(t *testing.T) {
|
func TestInit(t *testing.T) {
|
||||||
var a vector.Vector;
|
var a Vector;
|
||||||
if a.Init(0).Len() != 0 { t.Error("A") }
|
if a.Init(0).Len() != 0 { t.Error("A") }
|
||||||
if a.Init(1).Len() != 1 { t.Error("B") }
|
if a.Init(1).Len() != 1 { t.Error("B") }
|
||||||
if a.Init(10).Len() != 10 { t.Error("C") }
|
if a.Init(10).Len() != 10 { t.Error("C") }
|
||||||
@ -27,9 +27,9 @@ func TestInit(t *testing.T) {
|
|||||||
|
|
||||||
|
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
if vector.New(0).Len() != 0 { t.Error("A") }
|
if New(0).Len() != 0 { t.Error("A") }
|
||||||
if vector.New(1).Len() != 1 { t.Error("B") }
|
if New(1).Len() != 1 { t.Error("B") }
|
||||||
if vector.New(10).Len() != 10 { t.Error("C") }
|
if New(10).Len() != 10 { t.Error("C") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ func val(i int) int {
|
|||||||
|
|
||||||
func TestAccess(t *testing.T) {
|
func TestAccess(t *testing.T) {
|
||||||
const n = 100;
|
const n = 100;
|
||||||
var a vector.Vector;
|
var a Vector;
|
||||||
a.Init(n);
|
a.Init(n);
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
a.Set(i, val(i));
|
a.Set(i, val(i));
|
||||||
@ -53,7 +53,7 @@ func TestAccess(t *testing.T) {
|
|||||||
|
|
||||||
func TestInsertDeleteClear(t *testing.T) {
|
func TestInsertDeleteClear(t *testing.T) {
|
||||||
const n = 100;
|
const n = 100;
|
||||||
a := vector.New(0);
|
a := New(0);
|
||||||
|
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
if a.Len() != i { t.Errorf("A) wrong len %d (expected %d)", a.Len(), i) }
|
if a.Len() != i { t.Errorf("A) wrong len %d (expected %d)", a.Len(), i) }
|
||||||
@ -90,7 +90,7 @@ func TestInsertDeleteClear(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func verify_slice(t *testing.T, x *vector.Vector, elt, i, j int) {
|
func verify_slice(t *testing.T, x *Vector, elt, i, j int) {
|
||||||
for k := i; k < j; k++ {
|
for k := i; k < j; k++ {
|
||||||
if x.At(k).(int) != elt {
|
if x.At(k).(int) != elt {
|
||||||
t.Errorf("M) wrong [%d] element %d (expected %d)", k, x.At(k).(int), elt)
|
t.Errorf("M) wrong [%d] element %d (expected %d)", k, x.At(k).(int), elt)
|
||||||
@ -106,7 +106,7 @@ func verify_slice(t *testing.T, x *vector.Vector, elt, i, j int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func verify_pattern(t *testing.T, x *vector.Vector, a, b, c int) {
|
func verify_pattern(t *testing.T, x *Vector, a, b, c int) {
|
||||||
n := a + b + c;
|
n := a + b + c;
|
||||||
if x.Len() != n {
|
if x.Len() != n {
|
||||||
t.Errorf("O) wrong len %d (expected %d)", x.Len(), n)
|
t.Errorf("O) wrong len %d (expected %d)", x.Len(), n)
|
||||||
@ -117,8 +117,8 @@ func verify_pattern(t *testing.T, x *vector.Vector, a, b, c int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func make_vector(elt, len int) *vector.Vector {
|
func make_vector(elt, len int) *Vector {
|
||||||
x := vector.New(len);
|
x := New(len);
|
||||||
for i := 0; i < len; i++ {
|
for i := 0; i < len; i++ {
|
||||||
x.Set(i, elt);
|
x.Set(i, elt);
|
||||||
}
|
}
|
||||||
@ -154,13 +154,13 @@ func TestInsertVector(t *testing.T) {
|
|||||||
func TestSorting(t *testing.T) {
|
func TestSorting(t *testing.T) {
|
||||||
const n = 100;
|
const n = 100;
|
||||||
|
|
||||||
a := vector.NewIntVector(n);
|
a := NewIntVector(n);
|
||||||
for i := n-1; i >= 0; i-- {
|
for i := n-1; i >= 0; i-- {
|
||||||
a.Set(i, n-1-i);
|
a.Set(i, n-1-i);
|
||||||
}
|
}
|
||||||
if sort.IsSorted(a) { t.Error("int vector not sorted") }
|
if sort.IsSorted(a) { t.Error("int vector not sorted") }
|
||||||
|
|
||||||
b := vector.NewStringVector(n);
|
b := NewStringVector(n);
|
||||||
for i := n-1; i >= 0; i-- {
|
for i := n-1; i >= 0; i-- {
|
||||||
b.Set(i, fmt.Sprint(n-1-i));
|
b.Set(i, fmt.Sprint(n-1-i));
|
||||||
}
|
}
|
||||||
@ -171,13 +171,13 @@ func TestSorting(t *testing.T) {
|
|||||||
func TestDo(t *testing.T) {
|
func TestDo(t *testing.T) {
|
||||||
const n = 25;
|
const n = 25;
|
||||||
const salt = 17;
|
const salt = 17;
|
||||||
a := vector.NewIntVector(n);
|
a := NewIntVector(n);
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
a.Set(i, salt * i);
|
a.Set(i, salt * i);
|
||||||
}
|
}
|
||||||
count := 0;
|
count := 0;
|
||||||
a.Do(
|
a.Do(
|
||||||
func(e vector.Element) {
|
func(e Element) {
|
||||||
i := e.(int);
|
i := e.(int);
|
||||||
if i != count*salt {
|
if i != count*salt {
|
||||||
t.Error("value at", count, "should be", count*salt, "not", i)
|
t.Error("value at", count, "should be", count*salt, "not", i)
|
||||||
@ -192,7 +192,7 @@ func TestDo(t *testing.T) {
|
|||||||
|
|
||||||
func TestIter(t *testing.T) {
|
func TestIter(t *testing.T) {
|
||||||
const Len = 100;
|
const Len = 100;
|
||||||
x := vector.New(Len);
|
x := New(Len);
|
||||||
for i := 0; i < Len; i++ {
|
for i := 0; i < Len; i++ {
|
||||||
x.Set(i, i*i);
|
x.Set(i, i*i);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ type pp struct {
|
|||||||
|
|
||||||
func newPrinter() *pp {
|
func newPrinter() *pp {
|
||||||
p := new(pp);
|
p := new(pp);
|
||||||
p.fmt = fmt.New();
|
p.fmt = New();
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,11 +419,11 @@ func IsExported(name string) bool {
|
|||||||
|
|
||||||
// IsExported returns whether name is an exported Go symbol
|
// IsExported returns whether name is an exported Go symbol
|
||||||
// (i.e., whether it begins with an uppercase letter).
|
// (i.e., whether it begins with an uppercase letter).
|
||||||
func (name *ast.Ident) IsExported() bool {
|
func (name *Ident) IsExported() bool {
|
||||||
return IsExported(name.Value);
|
return IsExported(name.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
func (name *ast.Ident) String() string {
|
func (name *Ident) String() string {
|
||||||
return name.Value;
|
return name.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ func filterFieldList(list []*Field) []*Field {
|
|||||||
if j > 0 && j < len(list) {
|
if j > 0 && j < len(list) {
|
||||||
// fields have been stripped but there is at least one left;
|
// fields have been stripped but there is at least one left;
|
||||||
// add a '...' anonymous field instead
|
// add a '...' anonymous field instead
|
||||||
list[j] = &ast.Field{nil, nil, &ast.Ellipsis{}, nil, nil};
|
list[j] = &Field{nil, nil, &Ellipsis{}, nil, nil};
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
return list[0 : j];
|
return list[0 : j];
|
||||||
|
@ -78,7 +78,7 @@ func serveFileInternal(c *Conn, r *Request, name string, redirect bool) {
|
|||||||
// redirect to strip off any index.html
|
// redirect to strip off any index.html
|
||||||
n := len(name) - len(indexPage);
|
n := len(name) - len(indexPage);
|
||||||
if n >= 0 && name[n:len(name)] == indexPage {
|
if n >= 0 && name[n:len(name)] == indexPage {
|
||||||
http.Redirect(c, name[0:n+1], StatusMovedPermanently);
|
Redirect(c, name[0:n+1], StatusMovedPermanently);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,12 +103,12 @@ func serveFileInternal(c *Conn, r *Request, name string, redirect bool) {
|
|||||||
url := r.Url.Path;
|
url := r.Url.Path;
|
||||||
if d.IsDirectory() {
|
if d.IsDirectory() {
|
||||||
if url[len(url)-1] != '/' {
|
if url[len(url)-1] != '/' {
|
||||||
http.Redirect(c, url + "/", StatusMovedPermanently);
|
Redirect(c, url + "/", StatusMovedPermanently);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if url[len(url)-1] == '/' {
|
if url[len(url)-1] == '/' {
|
||||||
http.Redirect(c, url[0:len(url)-1], StatusMovedPermanently);
|
Redirect(c, url[0:len(url)-1], StatusMovedPermanently);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,102 +177,102 @@ func veryclose(a,b float64) bool {
|
|||||||
|
|
||||||
func TestAsin(t *testing.T) {
|
func TestAsin(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Asin(vf[i]/10); !veryclose(asin[i], f) {
|
if f := Asin(vf[i]/10); !veryclose(asin[i], f) {
|
||||||
t.Errorf("math.Asin(%g) = %g, want %g\n", vf[i]/10, f, asin[i]);
|
t.Errorf("Asin(%g) = %g, want %g\n", vf[i]/10, f, asin[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAtan(t *testing.T) {
|
func TestAtan(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Atan(vf[i]); !veryclose(atan[i], f) {
|
if f := Atan(vf[i]); !veryclose(atan[i], f) {
|
||||||
t.Errorf("math.Atan(%g) = %g, want %g\n", vf[i], f, atan[i]);
|
t.Errorf("Atan(%g) = %g, want %g\n", vf[i], f, atan[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExp(t *testing.T) {
|
func TestExp(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Exp(vf[i]); !veryclose(exp[i], f) {
|
if f := Exp(vf[i]); !veryclose(exp[i], f) {
|
||||||
t.Errorf("math.Exp(%g) = %g, want %g\n", vf[i], f, exp[i]);
|
t.Errorf("Exp(%g) = %g, want %g\n", vf[i], f, exp[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFloor(t *testing.T) {
|
func TestFloor(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Floor(vf[i]); floor[i] != f {
|
if f := Floor(vf[i]); floor[i] != f {
|
||||||
t.Errorf("math.Floor(%g) = %g, want %g\n", vf[i], f, floor[i]);
|
t.Errorf("Floor(%g) = %g, want %g\n", vf[i], f, floor[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLog(t *testing.T) {
|
func TestLog(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
a := math.Fabs(vf[i]);
|
a := Fabs(vf[i]);
|
||||||
if f := math.Log(a); log[i] != f {
|
if f := Log(a); log[i] != f {
|
||||||
t.Errorf("math.Log(%g) = %g, want %g\n", a, f, log[i]);
|
t.Errorf("Log(%g) = %g, want %g\n", a, f, log[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if f := math.Log(10); f != math.Ln10 {
|
if f := Log(10); f != Ln10 {
|
||||||
t.Errorf("math.Log(%g) = %g, want %g\n", 10, f, math.Ln10);
|
t.Errorf("Log(%g) = %g, want %g\n", 10, f, Ln10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPow(t *testing.T) {
|
func TestPow(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Pow(10, vf[i]); !close(pow[i], f) {
|
if f := Pow(10, vf[i]); !close(pow[i], f) {
|
||||||
t.Errorf("math.Pow(10, %.17g) = %.17g, want %.17g\n", vf[i], f, pow[i]);
|
t.Errorf("Pow(10, %.17g) = %.17g, want %.17g\n", vf[i], f, pow[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSin(t *testing.T) {
|
func TestSin(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Sin(vf[i]); !close(sin[i], f) {
|
if f := Sin(vf[i]); !close(sin[i], f) {
|
||||||
t.Errorf("math.Sin(%g) = %g, want %g\n", vf[i], f, sin[i]);
|
t.Errorf("Sin(%g) = %g, want %g\n", vf[i], f, sin[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSinh(t *testing.T) {
|
func TestSinh(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Sinh(vf[i]); !veryclose(sinh[i], f) {
|
if f := Sinh(vf[i]); !veryclose(sinh[i], f) {
|
||||||
t.Errorf("math.Sinh(%g) = %g, want %g\n", vf[i], f, sinh[i]);
|
t.Errorf("Sinh(%g) = %g, want %g\n", vf[i], f, sinh[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSqrt(t *testing.T) {
|
func TestSqrt(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
a := math.Fabs(vf[i]);
|
a := Fabs(vf[i]);
|
||||||
if f := math.Sqrt(a); !veryclose(sqrt[i], f) {
|
if f := Sqrt(a); !veryclose(sqrt[i], f) {
|
||||||
t.Errorf("math.Sqrt(%g) = %g, want %g\n", a, f, floor[i]);
|
t.Errorf("Sqrt(%g) = %g, want %g\n", a, f, floor[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTan(t *testing.T) {
|
func TestTan(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Tan(vf[i]); !close(tan[i], f) {
|
if f := Tan(vf[i]); !close(tan[i], f) {
|
||||||
t.Errorf("math.Tan(%g) = %g, want %g\n", vf[i], f, tan[i]);
|
t.Errorf("Tan(%g) = %g, want %g\n", vf[i], f, tan[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTanh(t *testing.T) {
|
func TestTanh(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
if f := math.Tanh(vf[i]); !veryclose(tanh[i], f) {
|
if f := Tanh(vf[i]); !veryclose(tanh[i], f) {
|
||||||
t.Errorf("math.Tanh(%g) = %g, want %g\n", vf[i], f, tanh[i]);
|
t.Errorf("Tanh(%g) = %g, want %g\n", vf[i], f, tanh[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHypot(t *testing.T) {
|
func TestHypot(t *testing.T) {
|
||||||
for i := 0; i < len(vf); i++ {
|
for i := 0; i < len(vf); i++ {
|
||||||
a := math.Fabs(tanh[i]*math.Sqrt(2));
|
a := Fabs(tanh[i]*Sqrt(2));
|
||||||
if f := math.Hypot(tanh[i], tanh[i]); !veryclose(a, f) {
|
if f := Hypot(tanh[i], tanh[i]); !veryclose(a, f) {
|
||||||
t.Errorf("math.Hypot(%g, %g) = %g, want %g\n", tanh[i], tanh[i], f, a);
|
t.Errorf("Hypot(%g, %g) = %g, want %g\n", tanh[i], tanh[i], f, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ var env map[string] string;
|
|||||||
|
|
||||||
func copyenv() {
|
func copyenv() {
|
||||||
env = make(map[string] string);
|
env = make(map[string] string);
|
||||||
for i, s := range os.Envs {
|
for i, s := range Envs {
|
||||||
for j := 0; j < len(s); j++ {
|
for j := 0; j < len(s); j++ {
|
||||||
if s[j] == '=' {
|
if s[j] == '=' {
|
||||||
env[s[0:j]] = s[j+1:len(s)];
|
env[s[0:j]] = s[j+1:len(s)];
|
||||||
|
@ -93,10 +93,10 @@ func (e *SyscallError) String() string {
|
|||||||
return e.Syscall + ": " + e.Errno.String();
|
return e.Syscall + ": " + e.Errno.String();
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSyscallError returns, as an os.Error, a new SyscallError
|
// NewSyscallError returns, as an Error, a new SyscallError
|
||||||
// with the given system call name and error number.
|
// with the given system call name and error number.
|
||||||
// As a convenience, if errno is 0, NewSyscallError returns nil.
|
// As a convenience, if errno is 0, NewSyscallError returns nil.
|
||||||
func NewSyscallError(syscall string, errno int) os.Error {
|
func NewSyscallError(syscall string, errno int) Error {
|
||||||
if errno == 0 {
|
if errno == 0 {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func Exec(argv0 string, argv []string, envv []string) Error {
|
|||||||
// TODO(rsc): Should os implement its own syscall.WaitStatus
|
// TODO(rsc): Should os implement its own syscall.WaitStatus
|
||||||
// wrapper with the methods, or is exposing the underlying one enough?
|
// wrapper with the methods, or is exposing the underlying one enough?
|
||||||
//
|
//
|
||||||
// TODO(rsc): Certainly need to have os.Rusage struct,
|
// TODO(rsc): Certainly need to have Rusage struct,
|
||||||
// since syscall one might have different field types across
|
// since syscall one might have different field types across
|
||||||
// different OS.
|
// different OS.
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ func (file *File) Close() Error {
|
|||||||
if file == nil {
|
if file == nil {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
}
|
}
|
||||||
var err os.Error;
|
var err Error;
|
||||||
if e := syscall.Close(file.fd); e != 0 {
|
if e := syscall.Close(file.fd); e != 0 {
|
||||||
err = &PathError{"close", file.name, Errno(e)};
|
err = &PathError{"close", file.name, Errno(e)};
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func (file *File) Write(b []byte) (ret int, err Error) {
|
|||||||
if e == syscall.EPIPE {
|
if e == syscall.EPIPE {
|
||||||
file.nepipe++;
|
file.nepipe++;
|
||||||
if file.nepipe >= 10 {
|
if file.nepipe >= 10 {
|
||||||
os.Exit(syscall.EPIPE);
|
Exit(syscall.EPIPE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
file.nepipe = 0;
|
file.nepipe = 0;
|
||||||
|
@ -15,7 +15,7 @@ import "os"
|
|||||||
// and returns nil.
|
// and returns nil.
|
||||||
func MkdirAll(path string, perm int) Error {
|
func MkdirAll(path string, perm int) Error {
|
||||||
// If path exists, stop with success or error.
|
// If path exists, stop with success or error.
|
||||||
dir, err := os.Lstat(path);
|
dir, err := Lstat(path);
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if dir.IsDirectory() {
|
if dir.IsDirectory() {
|
||||||
return nil;
|
return nil;
|
||||||
@ -47,7 +47,7 @@ func MkdirAll(path string, perm int) Error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// Handle arguments like "foo/." by
|
// Handle arguments like "foo/." by
|
||||||
// double-checking that directory doesn't exist.
|
// double-checking that directory doesn't exist.
|
||||||
dir, err1 := os.Lstat(path);
|
dir, err1 := Lstat(path);
|
||||||
if err1 == nil && dir.IsDirectory() {
|
if err1 == nil && dir.IsDirectory() {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ func RemoveAll(path string) Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, is this a directory we need to recurse into?
|
// Otherwise, is this a directory we need to recurse into?
|
||||||
dir, serr := os.Lstat(path);
|
dir, serr := Lstat(path);
|
||||||
if serr != nil {
|
if serr != nil {
|
||||||
if serr, ok := serr.(*PathError); ok && serr.Error == ENOENT {
|
if serr, ok := serr.(*PathError); ok && serr.Error == ENOENT {
|
||||||
return nil;
|
return nil;
|
||||||
@ -81,7 +81,7 @@ func RemoveAll(path string) Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Directory.
|
// Directory.
|
||||||
fd, err := Open(path, os.O_RDONLY, 0);
|
fd, err := Open(path, O_RDONLY, 0);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func TestMkdirAll(t *testing.T) {
|
|||||||
|
|
||||||
// Make file.
|
// Make file.
|
||||||
fpath := path + "/file";
|
fpath := path + "/file";
|
||||||
fd, err := os.Open(fpath, os.O_WRONLY | os.O_CREAT, 0666);
|
fd, err := Open(fpath, O_WRONLY | O_CREAT, 0666);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("create %q: %s", fpath, err);
|
t.Fatalf("create %q: %s", fpath, err);
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ func TestRemoveAll(t *testing.T) {
|
|||||||
if err := MkdirAll(path, 0777); err != nil {
|
if err := MkdirAll(path, 0777); err != nil {
|
||||||
t.Fatalf("MkdirAll %q: %s", path, err);
|
t.Fatalf("MkdirAll %q: %s", path, err);
|
||||||
}
|
}
|
||||||
fd, err := os.Open(fpath, os.O_WRONLY | os.O_CREAT, 0666);
|
fd, err := Open(fpath, O_WRONLY | O_CREAT, 0666);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("create %q: %s", fpath, err);
|
t.Fatalf("create %q: %s", fpath, err);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ func TestRemoveAll(t *testing.T) {
|
|||||||
if err = RemoveAll(path); err != nil {
|
if err = RemoveAll(path); err != nil {
|
||||||
t.Fatalf("RemoveAll %q (first): %s", path, err);
|
t.Fatalf("RemoveAll %q (first): %s", path, err);
|
||||||
}
|
}
|
||||||
if dir, err := os.Lstat(path); err == nil {
|
if dir, err := Lstat(path); err == nil {
|
||||||
t.Fatalf("Lstat %q succeeded after RemoveAll (first)", path);
|
t.Fatalf("Lstat %q succeeded after RemoveAll (first)", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,12 +87,12 @@ func TestRemoveAll(t *testing.T) {
|
|||||||
if err = MkdirAll(dpath, 0777); err != nil {
|
if err = MkdirAll(dpath, 0777); err != nil {
|
||||||
t.Fatalf("MkdirAll %q: %s", dpath, err);
|
t.Fatalf("MkdirAll %q: %s", dpath, err);
|
||||||
}
|
}
|
||||||
fd, err = os.Open(fpath, os.O_WRONLY | os.O_CREAT, 0666);
|
fd, err = Open(fpath, O_WRONLY | O_CREAT, 0666);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("create %q: %s", fpath, err);
|
t.Fatalf("create %q: %s", fpath, err);
|
||||||
}
|
}
|
||||||
fd.Close();
|
fd.Close();
|
||||||
fd, err = os.Open(dpath+"/file", os.O_WRONLY | os.O_CREAT, 0666);
|
fd, err = Open(dpath+"/file", O_WRONLY | O_CREAT, 0666);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("create %q: %s", fpath, err);
|
t.Fatalf("create %q: %s", fpath, err);
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ func TestRemoveAll(t *testing.T) {
|
|||||||
if err = RemoveAll(path); err != nil {
|
if err = RemoveAll(path); err != nil {
|
||||||
t.Fatalf("RemoveAll %q (second): %s", path, err);
|
t.Fatalf("RemoveAll %q (second): %s", path, err);
|
||||||
}
|
}
|
||||||
if dir, err := os.Lstat(path); err == nil {
|
if dir, err := Lstat(path); err == nil {
|
||||||
t.Fatalf("Lstat %q succeeded after RemoveAll (second)", path);
|
t.Fatalf("Lstat %q succeeded after RemoveAll (second)", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,13 +110,13 @@ func TestRemoveAll(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, s := range []string{fpath, dpath+"/file1", path+"/zzz"} {
|
for i, s := range []string{fpath, dpath+"/file1", path+"/zzz"} {
|
||||||
fd, err = os.Open(s, os.O_WRONLY | os.O_CREAT, 0666);
|
fd, err = Open(s, O_WRONLY | O_CREAT, 0666);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("create %q: %s", s, err);
|
t.Fatalf("create %q: %s", s, err);
|
||||||
}
|
}
|
||||||
fd.Close();
|
fd.Close();
|
||||||
}
|
}
|
||||||
if err = os.Chmod(dpath, 0); err != nil {
|
if err = Chmod(dpath, 0); err != nil {
|
||||||
t.Fatalf("Chmod %q 0: %s", dpath, err);
|
t.Fatalf("Chmod %q 0: %s", dpath, err);
|
||||||
}
|
}
|
||||||
if err = RemoveAll(path); err == nil {
|
if err = RemoveAll(path); err == nil {
|
||||||
@ -133,18 +133,18 @@ func TestRemoveAll(t *testing.T) {
|
|||||||
if perr.Path != dpath {
|
if perr.Path != dpath {
|
||||||
t.Fatalf("RemoveAll %q failed at %q not %q", path, perr.Path, dpath);
|
t.Fatalf("RemoveAll %q failed at %q not %q", path, perr.Path, dpath);
|
||||||
}
|
}
|
||||||
if err = os.Chmod(dpath, 0777); err != nil {
|
if err = Chmod(dpath, 0777); err != nil {
|
||||||
t.Fatalf("Chmod %q 0777: %s", dpath, err);
|
t.Fatalf("Chmod %q 0777: %s", dpath, err);
|
||||||
}
|
}
|
||||||
for i, s := range []string{fpath, path+"/zzz"} {
|
for i, s := range []string{fpath, path+"/zzz"} {
|
||||||
if dir, err := os.Lstat(s); err == nil {
|
if dir, err := Lstat(s); err == nil {
|
||||||
t.Fatalf("Lstat %q succeeded after partial RemoveAll", s);
|
t.Fatalf("Lstat %q succeeded after partial RemoveAll", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err = RemoveAll(path); err != nil {
|
if err = RemoveAll(path); err != nil {
|
||||||
t.Fatalf("RemoveAll %q after partial RemoveAll: %s", path, err);
|
t.Fatalf("RemoveAll %q after partial RemoveAll: %s", path, err);
|
||||||
}
|
}
|
||||||
if dir, err := os.Lstat(path); err == nil {
|
if dir, err := Lstat(path); err == nil {
|
||||||
t.Fatalf("Lstat %q succeeded after RemoveAll (final)", path);
|
t.Fatalf("Lstat %q succeeded after RemoveAll (final)", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func Getegid() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Getgroups returns a list of the numeric ids of groups that the caller belongs to.
|
// Getgroups returns a list of the numeric ids of groups that the caller belongs to.
|
||||||
func Getgroups() ([]int, os.Error) {
|
func Getgroups() ([]int, Error) {
|
||||||
gids, errno := syscall.Getgroups();
|
gids, errno := syscall.Getgroups();
|
||||||
return gids, NewSyscallError("getgroups", errno);
|
return gids, NewSyscallError("getgroups", errno);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"syscall";
|
"syscall";
|
||||||
)
|
)
|
||||||
|
|
||||||
func Hostname() (name string, err os.Error) {
|
func Hostname() (name string, err Error) {
|
||||||
var errno int;
|
var errno int;
|
||||||
name, errno = syscall.Sysctl("kern.hostname");
|
name, errno = syscall.Sysctl("kern.hostname");
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
|
@ -9,7 +9,7 @@ package os
|
|||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
// Hostname returns the host name reported by the kernel.
|
// Hostname returns the host name reported by the kernel.
|
||||||
func Hostname() (name string, err os.Error) {
|
func Hostname() (name string, err Error) {
|
||||||
f, err := Open("/proc/sys/kernel/hostname", O_RDONLY, 0);
|
f, err := Open("/proc/sys/kernel/hostname", O_RDONLY, 0);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err;
|
return "", err;
|
||||||
|
@ -433,7 +433,7 @@ func (v *UnsafePointerValue) Set(x unsafe.Pointer) {
|
|||||||
*(*unsafe.Pointer)(v.addr) = x;
|
*(*unsafe.Pointer)(v.addr) = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
func typesMustMatch(t1, t2 reflect.Type) {
|
func typesMustMatch(t1, t2 Type) {
|
||||||
if t1 != t2 {
|
if t1 != t2 {
|
||||||
panicln("type mismatch:", t1.String(), "!=", t2.String());
|
panicln("type mismatch:", t1.String(), "!=", t2.String());
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"unsafe";
|
"unsafe";
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(rsc): This implementation of time.Tick is a
|
// TODO(rsc): This implementation of Tick is a
|
||||||
// simple placeholder. Eventually, there will need to be
|
// simple placeholder. Eventually, there will need to be
|
||||||
// a single central time server no matter how many tickers
|
// a single central time server no matter how many tickers
|
||||||
// are active. There also needs to be a way to cancel a ticker.
|
// are active. There also needs to be a way to cancel a ticker.
|
||||||
@ -21,13 +21,13 @@ import (
|
|||||||
// func Ticker(ns int64, c chan int64) {
|
// func Ticker(ns int64, c chan int64) {
|
||||||
// for {
|
// for {
|
||||||
// select { timeout ns: }
|
// select { timeout ns: }
|
||||||
// nsec, err := time.Nanoseconds();
|
// nsec, err := Nanoseconds();
|
||||||
// c <- nsec;
|
// c <- nsec;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func ticker(ns int64, c chan int64) {
|
func ticker(ns int64, c chan int64) {
|
||||||
var tv syscall.Timeval;
|
var tv syscall.Timeval;
|
||||||
now := time.Nanoseconds();
|
now := Nanoseconds();
|
||||||
when := now;
|
when := now;
|
||||||
for {
|
for {
|
||||||
when += ns; // next alarm
|
when += ns; // next alarm
|
||||||
@ -42,8 +42,8 @@ func ticker(ns int64, c chan int64) {
|
|||||||
when += ns
|
when += ns
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(when - now);
|
Sleep(when - now);
|
||||||
now = time.Nanoseconds();
|
now = Nanoseconds();
|
||||||
c <- now;
|
c <- now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ func UTC() *Time {
|
|||||||
// SecondsToLocalTime converts sec, in number of seconds since the Unix epoch,
|
// SecondsToLocalTime converts sec, in number of seconds since the Unix epoch,
|
||||||
// into a parsed Time value in the local time zone.
|
// into a parsed Time value in the local time zone.
|
||||||
func SecondsToLocalTime(sec int64) *Time {
|
func SecondsToLocalTime(sec int64) *Time {
|
||||||
z, offset := time.lookupTimezone(sec);
|
z, offset := lookupTimezone(sec);
|
||||||
t := SecondsToUTC(sec+int64(offset));
|
t := SecondsToUTC(sec+int64(offset));
|
||||||
t.Zone = z;
|
t.Zone = z;
|
||||||
t.ZoneOffset = offset;
|
t.ZoneOffset = offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user