Skip to content

Commit 670bae4

Browse files
kielbarrykaralabe
authored andcommitted
internal: golint updates for this or self warning (#16634)
1 parent 4a8d5d2 commit 670bae4

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

internal/jsre/jsre.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ func randomSource() *rand.Rand {
102102
// call the functions of the otto vm directly to circumvent the queue. These
103103
// functions should be used if and only if running a routine that was already
104104
// called from JS through an RPC call.
105-
func (self *JSRE) runEventLoop() {
106-
defer close(self.closed)
105+
func (re *JSRE) runEventLoop() {
106+
defer close(re.closed)
107107

108108
vm := otto.New()
109109
r := randomSource()
@@ -202,14 +202,14 @@ loop:
202202
break loop
203203
}
204204
}
205-
case req := <-self.evalQueue:
205+
case req := <-re.evalQueue:
206206
// run the code, send the result back
207207
req.fn(vm)
208208
close(req.done)
209209
if waitForCallbacks && (len(registry) == 0) {
210210
break loop
211211
}
212-
case waitForCallbacks = <-self.stopEventLoop:
212+
case waitForCallbacks = <-re.stopEventLoop:
213213
if !waitForCallbacks || (len(registry) == 0) {
214214
break loop
215215
}
@@ -223,31 +223,31 @@ loop:
223223
}
224224

225225
// Do executes the given function on the JS event loop.
226-
func (self *JSRE) Do(fn func(*otto.Otto)) {
226+
func (re *JSRE) Do(fn func(*otto.Otto)) {
227227
done := make(chan bool)
228228
req := &evalReq{fn, done}
229-
self.evalQueue <- req
229+
re.evalQueue <- req
230230
<-done
231231
}
232232

233233
// stops the event loop before exit, optionally waits for all timers to expire
234-
func (self *JSRE) Stop(waitForCallbacks bool) {
234+
func (re *JSRE) Stop(waitForCallbacks bool) {
235235
select {
236-
case <-self.closed:
237-
case self.stopEventLoop <- waitForCallbacks:
238-
<-self.closed
236+
case <-re.closed:
237+
case re.stopEventLoop <- waitForCallbacks:
238+
<-re.closed
239239
}
240240
}
241241

242242
// Exec(file) loads and runs the contents of a file
243243
// if a relative path is given, the jsre's assetPath is used
244-
func (self *JSRE) Exec(file string) error {
245-
code, err := ioutil.ReadFile(common.AbsolutePath(self.assetPath, file))
244+
func (re *JSRE) Exec(file string) error {
245+
code, err := ioutil.ReadFile(common.AbsolutePath(re.assetPath, file))
246246
if err != nil {
247247
return err
248248
}
249249
var script *otto.Script
250-
self.Do(func(vm *otto.Otto) {
250+
re.Do(func(vm *otto.Otto) {
251251
script, err = vm.Compile(file, code)
252252
if err != nil {
253253
return
@@ -259,36 +259,36 @@ func (self *JSRE) Exec(file string) error {
259259

260260
// Bind assigns value v to a variable in the JS environment
261261
// This method is deprecated, use Set.
262-
func (self *JSRE) Bind(name string, v interface{}) error {
263-
return self.Set(name, v)
262+
func (re *JSRE) Bind(name string, v interface{}) error {
263+
return re.Set(name, v)
264264
}
265265

266266
// Run runs a piece of JS code.
267-
func (self *JSRE) Run(code string) (v otto.Value, err error) {
268-
self.Do(func(vm *otto.Otto) { v, err = vm.Run(code) })
267+
func (re *JSRE) Run(code string) (v otto.Value, err error) {
268+
re.Do(func(vm *otto.Otto) { v, err = vm.Run(code) })
269269
return v, err
270270
}
271271

272272
// Get returns the value of a variable in the JS environment.
273-
func (self *JSRE) Get(ns string) (v otto.Value, err error) {
274-
self.Do(func(vm *otto.Otto) { v, err = vm.Get(ns) })
273+
func (re *JSRE) Get(ns string) (v otto.Value, err error) {
274+
re.Do(func(vm *otto.Otto) { v, err = vm.Get(ns) })
275275
return v, err
276276
}
277277

278278
// Set assigns value v to a variable in the JS environment.
279-
func (self *JSRE) Set(ns string, v interface{}) (err error) {
280-
self.Do(func(vm *otto.Otto) { err = vm.Set(ns, v) })
279+
func (re *JSRE) Set(ns string, v interface{}) (err error) {
280+
re.Do(func(vm *otto.Otto) { err = vm.Set(ns, v) })
281281
return err
282282
}
283283

284284
// loadScript executes a JS script from inside the currently executing JS code.
285-
func (self *JSRE) loadScript(call otto.FunctionCall) otto.Value {
285+
func (re *JSRE) loadScript(call otto.FunctionCall) otto.Value {
286286
file, err := call.Argument(0).ToString()
287287
if err != nil {
288288
// TODO: throw exception
289289
return otto.FalseValue()
290290
}
291-
file = common.AbsolutePath(self.assetPath, file)
291+
file = common.AbsolutePath(re.assetPath, file)
292292
source, err := ioutil.ReadFile(file)
293293
if err != nil {
294294
// TODO: throw exception
@@ -305,10 +305,10 @@ func (self *JSRE) loadScript(call otto.FunctionCall) otto.Value {
305305

306306
// Evaluate executes code and pretty prints the result to the specified output
307307
// stream.
308-
func (self *JSRE) Evaluate(code string, w io.Writer) error {
308+
func (re *JSRE) Evaluate(code string, w io.Writer) error {
309309
var fail error
310310

311-
self.Do(func(vm *otto.Otto) {
311+
re.Do(func(vm *otto.Otto) {
312312
val, err := vm.Run(code)
313313
if err != nil {
314314
prettyError(vm, err, w)
@@ -321,8 +321,8 @@ func (self *JSRE) Evaluate(code string, w io.Writer) error {
321321
}
322322

323323
// Compile compiles and then runs a piece of JS code.
324-
func (self *JSRE) Compile(filename string, src interface{}) (err error) {
325-
self.Do(func(vm *otto.Otto) { _, err = compileAndRun(vm, filename, src) })
324+
func (re *JSRE) Compile(filename string, src interface{}) (err error) {
325+
re.Do(func(vm *otto.Otto) { _, err = compileAndRun(vm, filename, src) })
326326
return err
327327
}
328328

0 commit comments

Comments
 (0)