Fix all the linting problems through out the bootstrap dir

This commit is contained in:
Sameer Rahmani 2021-01-25 18:37:19 +00:00
parent 23d397b94e
commit f8d8256d29
5 changed files with 37 additions and 35 deletions

View File

@ -15,6 +15,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cmd
import (
@ -33,6 +34,6 @@ var replCmd = &cobra.Command{
},
}
func init() {
func init() { // nolint:gochecknoinits
rootCmd.AddCommand(replCmd)
}

View File

@ -15,6 +15,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Package cmd provides the sub commands for the Serene binary.
package cmd
import (
@ -62,7 +64,7 @@ func Execute() {
}
}
func init() {
func init() { // nolint:gochecknoinits
cobra.OnInitialize()
rootCmd.PersistentFlags().BoolVar(
&debugMode,
@ -75,5 +77,4 @@ func init() {
"debug-stack",
false,
"Turns on the call stack debug mode.")
}

View File

@ -15,6 +15,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cmd
import (
@ -32,6 +33,6 @@ var runCmd = &cobra.Command{
},
}
func init() {
func init() { // nolint:gochecknoinits
rootCmd.AddCommand(runCmd)
}

View File

@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Package dl provides the necessary interface to interact with share
// libraries
package dl
/*
@ -44,43 +46,39 @@ static void* shareLibLookup(uintptr_t h, const char* name, char** err) {
return r;
}
*/
import "C"
import (
"fmt"
"unsafe"
)
type SharedLib struct{}
// import "C"
// import (
// "fmt"
// "unsafe"
// )
func Open(libPath string) (*SharedLib, error) {
cPath := make([]byte, C.PATH_MAX+1)
cRelName := make([]byte, len(libPath)+1)
copy(cRelName, libPath)
// type SharedLib struct{}
// If the given libPath exists, fill the cPath with the absolute path
// to the file (it follows symlinks).
if C.realpath(
(*C.char)(unsafe.Pointer(&cRelName[0])),
(*C.char)(unsafe.Pointer(&cPath[0]))) == nil {
return nil, fmt.Errorf("can't find the shared library '%s'", libPath)
}
// func Open(libPath string) (*SharedLib, error) {
// cPath := make([]byte, C.PATH_MAX+1)
// cRelName := make([]byte, len(libPath)+1)
// copy(cRelName, libPath)
//filepath := C.GoString((*C.char)(unsafe.Pointer(&cPath[0])))
// // If the given libPath exists, fill the cPath with the absolute path
// // to the file (it follows symlinks).
// if C.realpath(
// (*C.char)(unsafe.Pointer(&cRelName[0])),
// (*C.char)(unsafe.Pointer(&cPath[0]))) == nil {
// return nil, fmt.Errorf("can't find the shared library '%s'", libPath)
// }
var cErr *C.char
h := C.openShareLib((*C.char)(unsafe.Pointer(&cPath[0])), &cErr)
// var cErr *C.char
// h := C.openShareLib((*C.char)(unsafe.Pointer(&cPath[0])), &cErr)
if h == 0 {
// lock.Unlock()
return nil, fmt.Errorf("failed to open shared library: '%s' due to: '%s'", libPath, C.GoString(cErr))
}
// if h == 0 {
// // lock.Unlock()
// return nil, fmt.Errorf("failed to open shared library: '%s' due to: '%s'", libPath, C.GoString(cErr))
// }
// if plugins == nil {
// plugins = make(map[string]*Plugin)
// }
initTask := C.shareLibLookup(h, C.CString("bar"), &cErr)
// initTask := C.shareLibLookup(h, C.CString("bar"), &cErr)
fmt.Printf(">> %p \n", initTask)
// fmt.Printf(">> %p \n", initTask)
return &SharedLib{}, nil
}
// return &SharedLib{}, nil
// }

View File

@ -15,6 +15,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package main
import "serene-lang.org/bootstrap/cmd"