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 You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package cmd package cmd
import ( import (
@ -33,6 +34,6 @@ var replCmd = &cobra.Command{
}, },
} }
func init() { func init() { // nolint:gochecknoinits
rootCmd.AddCommand(replCmd) 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 You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// Package cmd provides the sub commands for the Serene binary.
package cmd package cmd
import ( import (
@ -62,7 +64,7 @@ func Execute() {
} }
} }
func init() { func init() { // nolint:gochecknoinits
cobra.OnInitialize() cobra.OnInitialize()
rootCmd.PersistentFlags().BoolVar( rootCmd.PersistentFlags().BoolVar(
&debugMode, &debugMode,
@ -75,5 +77,4 @@ func init() {
"debug-stack", "debug-stack",
false, false,
"Turns on the call stack debug mode.") "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 You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package cmd package cmd
import ( import (
@ -32,6 +33,6 @@ var runCmd = &cobra.Command{
}, },
} }
func init() { func init() { // nolint:gochecknoinits
rootCmd.AddCommand(runCmd) 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/>. 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 package dl
/* /*
@ -44,43 +46,39 @@ static void* shareLibLookup(uintptr_t h, const char* name, char** err) {
return r; return r;
} }
*/ */
import "C"
import (
"fmt"
"unsafe"
)
type SharedLib struct{} // import "C"
// import (
// "fmt"
// "unsafe"
// )
func Open(libPath string) (*SharedLib, error) { // type SharedLib struct{}
cPath := make([]byte, C.PATH_MAX+1)
cRelName := make([]byte, len(libPath)+1)
copy(cRelName, libPath)
// If the given libPath exists, fill the cPath with the absolute path // func Open(libPath string) (*SharedLib, error) {
// to the file (it follows symlinks). // cPath := make([]byte, C.PATH_MAX+1)
if C.realpath( // cRelName := make([]byte, len(libPath)+1)
(*C.char)(unsafe.Pointer(&cRelName[0])), // copy(cRelName, libPath)
(*C.char)(unsafe.Pointer(&cPath[0]))) == nil {
return nil, fmt.Errorf("can't find the shared library '%s'", 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 // var cErr *C.char
h := C.openShareLib((*C.char)(unsafe.Pointer(&cPath[0])), &cErr) // h := C.openShareLib((*C.char)(unsafe.Pointer(&cPath[0])), &cErr)
if h == 0 { // if h == 0 {
// lock.Unlock() // // lock.Unlock()
return nil, fmt.Errorf("failed to open shared library: '%s' due to: '%s'", libPath, C.GoString(cErr)) // return nil, fmt.Errorf("failed to open shared library: '%s' due to: '%s'", libPath, C.GoString(cErr))
} // }
// if plugins == nil { // initTask := C.shareLibLookup(h, C.CString("bar"), &cErr)
// plugins = make(map[string]*Plugin)
// }
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 You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package main package main
import "serene-lang.org/bootstrap/cmd" import "serene-lang.org/bootstrap/cmd"