impi icon indicating copy to clipboard operation
impi copied to clipboard

Ignore C directive in comments before 'import "C"`

Open tebeka opened this issue 8 years ago • 2 comments

If we have code like:

import (
	"fmt"
	"net/http"
	"os"
	goruntime "runtime"
	"strings"
	"unsafe"

	"github.com/nuclio/nuclio/pkg/errors"
	"github.com/nuclio/nuclio/pkg/processor/runtime"

	"github.com/nuclio/logger"
	"github.com/nuclio/nuclio-sdk-go"
)

/*
#include <Python.h>
#include <stdlib.h>
#include "types.h"

extern response_t call_handler(unsigned long event_ptr, unsigned long logger_ptr);
extern char *py_last_error();
void free_response_t(response_t response);
*/
import "C"

Then impi thinks there are 4 import groups due to the empty line in the comment before `import "C"

$ impi --local github.com/nuclio/nuclio/ --scheme stdLocalThirdParty ./cmd/... ./pkg/...
pkg/processor/runtime/python3/runtime.go: Expected no more than 3 groups, got 4

If we remove the empty line after #include "types.h" then impi is happy.

tebeka avatar Feb 07 '18 14:02 tebeka

Do you think the proper method is to ignore import "C"?

pavius avatar Feb 07 '18 14:02 pavius

Not sure. IMO import "C" is it's own group.

tebeka avatar Feb 07 '18 15:02 tebeka