OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 Package runtime contains operations that interact with Go's runtime system, | 6 Package runtime contains operations that interact with Go's runtime system, |
7 such as functions to control goroutines. It also includes the low-level type inf
ormation | 7 such as functions to control goroutines. It also includes the low-level type inf
ormation |
8 used by the reflect package; see reflect's documentation for the programmable | 8 used by the reflect package; see reflect's documentation for the programmable |
9 interface to the run-time type system. | 9 interface to the run-time type system. |
10 | 10 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 func Callers(skip int, pc []uintptr) int { | 119 func Callers(skip int, pc []uintptr) int { |
120 // runtime.callers uses pc.array==nil as a signal | 120 // runtime.callers uses pc.array==nil as a signal |
121 // to print a stack trace. Pick off 0-length pc here | 121 // to print a stack trace. Pick off 0-length pc here |
122 // so that we don't let a nil pc slice get to it. | 122 // so that we don't let a nil pc slice get to it. |
123 if len(pc) == 0 { | 123 if len(pc) == 0 { |
124 return 0 | 124 return 0 |
125 } | 125 } |
126 return callers(skip, &pc[0], len(pc)) | 126 return callers(skip, &pc[0], len(pc)) |
127 } | 127 } |
128 | 128 |
129 func getgoroot() string | |
130 | |
131 // GOROOT returns the root of the Go tree. | 129 // GOROOT returns the root of the Go tree. |
132 // It uses the GOROOT environment variable, if set, | 130 // It uses the GOROOT environment variable, if set, |
133 // or else the root used during the Go build. | 131 // or else the root used during the Go build. |
134 func GOROOT() string { | 132 func GOROOT() string { |
135 s := gogetenv("GOROOT") | 133 s := gogetenv("GOROOT") |
136 if s != "" { | 134 if s != "" { |
137 return s | 135 return s |
138 } | 136 } |
139 return defaultGoroot | 137 return defaultGoroot |
140 } | 138 } |
141 | 139 |
142 // Version returns the Go tree's version string. | 140 // Version returns the Go tree's version string. |
143 // It is either the commit hash and date at the time of the build or, | 141 // It is either the commit hash and date at the time of the build or, |
144 // when possible, a release tag like "go1.3". | 142 // when possible, a release tag like "go1.3". |
145 func Version() string { | 143 func Version() string { |
146 return theVersion | 144 return theVersion |
147 } | 145 } |
148 | 146 |
149 // GOOS is the running program's operating system target: | 147 // GOOS is the running program's operating system target: |
150 // one of darwin, freebsd, linux, and so on. | 148 // one of darwin, freebsd, linux, and so on. |
151 const GOOS string = theGoos | 149 const GOOS string = theGoos |
152 | 150 |
153 // GOARCH is the running program's architecture target: | 151 // GOARCH is the running program's architecture target: |
154 // 386, amd64, or arm. | 152 // 386, amd64, or arm. |
155 const GOARCH string = theGoarch | 153 const GOARCH string = theGoarch |
OLD | NEW |