github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/cmd/fix/egltype.go (about)

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"go/ast"
     9  )
    10  
    11  func init() {
    12  	register(eglFix)
    13  }
    14  
    15  var eglFix = fix{
    16  	name:     "egl",
    17  	date:     "2018-12-15",
    18  	f:        eglfix,
    19  	desc:     `Fixes initializers of EGLDisplay`,
    20  	disabled: false,
    21  }
    22  
    23  // Old state:
    24  //   type EGLDisplay unsafe.Pointer
    25  // New state:
    26  //   type EGLDisplay uintptr
    27  // This fix finds nils initializing these types and replaces the nils with 0s.
    28  func eglfix(f *ast.File) bool {
    29  	return typefix(f, func(s string) bool {
    30  		return s == "C.EGLDisplay"
    31  	})
    32  }