diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000000000000000000000000000000000000..981200e8a89d8f297abb8a5d2390ffcf0f36fb15 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,83 @@ +run: + deadline: 5m + tests: true + modules-download-mode: readonly +output: + format: colored-line-number + print-issued-lines: true + print-linter-name: true +linters-settings: + depguard: + list-type: blacklist + include-go-root: true + packages: + - log + - github.com/satori/go.uuid + errcheck: + check-type-assertions: true + check-blank: true + goconst: + min-len: 3 + min-occurrences: 3 + gocritic: + enabled-tags: + - diagnostic + - performance + - style + - opinionated + - experimental + disabled-checks: + - sloppyReassign + gofmt: + simplify: true + golint: + min-confidence: 0.8 + govet: + check-shadowing: true + maligned: + suggest-new: true + misspell: + locale: US + prealloc: + simple: true + range-loops: true + for-loops: false + unused: + check-exported: false +linters: + disable-all: true + enable: + - deadcode + - depguard + - errcheck + - goconst + - gocritic + - gofmt + - goimports + - golint + - gosec + - gosimple + - govet + - ineffassign + - interfacer + - maligned + - misspell + - prealloc + - scopelint + - staticcheck + - structcheck + - unconvert + - unused + - varcheck +issues: + max-per-linter: 20 + max-same-issues: 3 + new: false + exclude-use-default: false + exclude: + - should call os.Exit to set exit code + - "G301: Expect directory permissions to be 0750 or less" + - "G302: Expect file permissions to be 0600 or less" + - "G304: Potential file inclusion via variable" + - "G104: Errors unhandled" + - "G204: Subprocess launched with variable" diff --git a/cef/DeleteCookiesCallback_gen.go b/cef/DeleteCookiesCallback_gen.go index 1b079ff49a8d7da54d47cf942b9556fe0c7324a5..930386c900cdd3b9c161520cdb5abce96f40896e 100644 --- a/cef/DeleteCookiesCallback_gen.go +++ b/cef/DeleteCookiesCallback_gen.go @@ -55,7 +55,7 @@ func (d *DeleteCookiesCallback) Base() *BaseRefCounted { // OnComplete (on_complete) // Method that will be called upon completion. |num_deleted| will be the -// number of cookies that were deleted or -1 if unknown. +// number of cookies that were deleted. func (d *DeleteCookiesCallback) OnComplete(num_deleted int32) { lookupDeleteCookiesCallbackProxy(d.Base()).OnComplete(d, num_deleted) } diff --git a/cef/MainArgs.go b/cef/MainArgs.go index 8cc88b5aaf3b9381531132342c56f5652da5d056..e6d80ad57c4969c5a3fa359192162be458134f8f 100644 --- a/cef/MainArgs.go +++ b/cef/MainArgs.go @@ -30,7 +30,3 @@ func (d *MainArgs) toNative(native *C.cef_main_args_t) *C.cef_main_args_t { *native = d.native return native } - -func (d *MainArgs) fromNative(native *C.cef_main_args_t) { - d.native = *native -} diff --git a/cef/RequestContext_gen.go b/cef/RequestContext_gen.go index 9a06daa408edcf8325b982509854079a8f0a9772..bf1c6abd3cf47d66565028c912fb516fd669e993 100644 --- a/cef/RequestContext_gen.go +++ b/cef/RequestContext_gen.go @@ -21,7 +21,6 @@ import ( // void gocef_request_context_clear_certificate_exceptions(cef_request_context_t * self, cef_completion_callback_t * callback, void (CEF_CALLBACK *callback__)(cef_request_context_t *, cef_completion_callback_t *)) { return callback__(self, callback); } // void gocef_request_context_close_all_connections(cef_request_context_t * self, cef_completion_callback_t * callback, void (CEF_CALLBACK *callback__)(cef_request_context_t *, cef_completion_callback_t *)) { return callback__(self, callback); } // void gocef_request_context_resolve_host(cef_request_context_t * self, cef_string_t * origin, cef_resolve_callback_t * callback, void (CEF_CALLBACK *callback__)(cef_request_context_t *, cef_string_t *, cef_resolve_callback_t *)) { return callback__(self, origin, callback); } - // cef_errorcode_t gocef_request_context_resolve_host_cached(cef_request_context_t * self, cef_string_t * origin, cef_string_list_t resolved_ips, cef_errorcode_t (CEF_CALLBACK *callback__)(cef_request_context_t *, cef_string_t *, cef_string_list_t)) { return callback__(self, origin, resolved_ips); } // void gocef_request_context_load_extension(cef_request_context_t * self, cef_string_t * root_directory, cef_dictionary_value_t * manifest, cef_extension_handler_t * handler, void (CEF_CALLBACK *callback__)(cef_request_context_t *, cef_string_t *, cef_dictionary_value_t *, cef_extension_handler_t *)) { return callback__(self, root_directory, manifest, handler); } // int gocef_request_context_did_load_extension(cef_request_context_t * self, cef_string_t * extension_id, int (CEF_CALLBACK *callback__)(cef_request_context_t *, cef_string_t *)) { return callback__(self, extension_id); } // int gocef_request_context_has_extension(cef_request_context_t * self, cef_string_t * extension_id, int (CEF_CALLBACK *callback__)(cef_request_context_t *, cef_string_t *)) { return callback__(self, extension_id); } @@ -252,20 +251,6 @@ func (d *RequestContext) ResolveHost(origin string, callback *ResolveCallback) { C.gocef_request_context_resolve_host(d.toNative(), (*C.cef_string_t)(origin_), callback.toNative(), d.resolve_host) } -// ResolveHostCached (resolve_host_cached) -// Attempts to resolve |origin| to a list of associated IP addresses using -// cached data. |resolved_ips| will be populated with the list of resolved IP -// addresses or NULL if no cached data is available. Returns ERR_NONE on -// success. This function must be called on the browser process IO thread. -func (d *RequestContext) ResolveHostCached(origin string, resolved_ips StringList) Errorcode { - origin_ := C.cef_string_userfree_alloc() - setCEFStr(origin, origin_) - defer func() { - C.cef_string_userfree_free(origin_) - }() - return Errorcode(C.gocef_request_context_resolve_host_cached(d.toNative(), (*C.cef_string_t)(origin_), C.cef_string_list_t(resolved_ips), d.resolve_host_cached)) -} - // LoadExtension (load_extension) // Load an extension. // diff --git a/cef/string.go b/cef/string.go index ee3c1384ef4fc903dac20e1ce5cfd754274f0dbf..38cb3dcb2085a5e063ca4885f77a4e8a3a95d3a9 100644 --- a/cef/string.go +++ b/cef/string.go @@ -8,14 +8,6 @@ import ( "unsafe" ) -func newCEFStr(str string) *C.cef_string_t { - utf8str := C.CString(str) - cefstr := (*C.cef_string_t)(C.calloc(1, C.size_t(unsafe.Sizeof(C.cef_string_t{})))) - C.cef_string_from_utf8(utf8str, C.strlen(utf8str), cefstr) - C.free(unsafe.Pointer(utf8str)) - return cefstr -} - func setCEFStr(str string, cefStr *C.cef_string_t) { utf8str := C.CString(str) C.cef_string_from_utf8(utf8str, C.strlen(utf8str), cefStr) diff --git a/go.mod b/go.mod index 08ede1d01a89b03670acadf8ce91641ccaf7472b..f774ad5eca060323a4bbc01047f3cbe947df0f83 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/richardwilkes/cef -require github.com/richardwilkes/toolbox v1.5.0 +require github.com/richardwilkes/toolbox v1.6.1 diff --git a/go.sum b/go.sum index 432a44fe6a2ed65470eb4323faef73d492600b9b..a22342dc0fa96634deaf00d8d1cf77aa88c75a16 100644 --- a/go.sum +++ b/go.sum @@ -6,13 +6,13 @@ github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/richardwilkes/toolbox v1.5.0 h1:8HkK68pUD20ZYiSFUWing23bSPkJHuMTkR8TdUzoobA= -github.com/richardwilkes/toolbox v1.5.0/go.mod h1:BhrbXd529SOF8vK4ve7ABji9fvItLH7+5sVpnqVQCvs= +github.com/richardwilkes/toolbox v1.6.1 h1:mC97qYjledp68mpg9yiM25SXYJIjKuvt0s3s0pitmrY= +github.com/richardwilkes/toolbox v1.6.1/go.mod h1:/3ynfaWs6sEF5hZEN3ANCDLOvFwaWmHi1AnlmHmaAqM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc h1:4gbWbmmPFp4ySWICouJl6emP0MyS31yy9SrTlAGFT+g= -golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190520201301-c432e742b0af h1:NXfmMfXz6JqGfG3ikSxcz2N93j6DgScr19Oo2uwFu88= +golang.org/x/sys v0.0.0-20190520201301-c432e742b0af/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/internal/cefgen/field.go b/internal/cefgen/field.go index ae5902c6533e544085267e408c310327f442c3b7..20a83b519df1416cb8921d0e19c018d2933992df 100644 --- a/internal/cefgen/field.go +++ b/internal/cefgen/field.go @@ -62,7 +62,7 @@ type param struct { func (f *field) processedCParams(in []string) []param { params := make([]param, len(in)) for i, p := range in { - p = strings.Replace(p, "const ", "", -1) + p = strings.ReplaceAll(p, "const ", "") if space := strings.Index(p, " "); space != -1 { params[i] = param{ Type: p[:space], diff --git a/internal/cefgen/main.go b/internal/cefgen/main.go index d034d64beb6f52a6eb2049c9fdf8d7fdc000616c..b0ccea36d0f822e24c67fc8c689a3032ffac6e57 100644 --- a/internal/cefgen/main.go +++ b/internal/cefgen/main.go @@ -65,7 +65,7 @@ func cleanOutput() { func examineCEFSource(headers []string) { var err error - cmd := exec.Command("clang", clangArgs(headers)...) + cmd := exec.Command("clang", clangArgs(headers)...) //nolint:gosec cmd.Dir, err = filepath.Abs(cefBaseDir) jot.FatalIfErr(err) stdout, err := cmd.StdoutPipe() diff --git a/internal/cefgen/variable.go b/internal/cefgen/variable.go index af73f38740a248ff74e1dd7363035a0d2fe9a7e8..08d229dd6b68ec2de880d145d52a33b465224c29 100644 --- a/internal/cefgen/variable.go +++ b/internal/cefgen/variable.go @@ -74,11 +74,11 @@ func newCVar(name, typeInfo string, pos position) *variable { } if v.HadConst = strings.Contains(typeInfo, "const "); v.HadConst { - typeInfo = strings.Replace(typeInfo, "const ", "", -1) + typeInfo = strings.ReplaceAll(typeInfo, "const ", "") } typeInfo = strings.TrimSpace(typeInfo) typeInfo = strings.TrimPrefix(typeInfo, "struct _") - typeInfo = strings.Replace(typeInfo, "long long", "longlong", -1) + typeInfo = strings.ReplaceAll(typeInfo, "long long", "longlong") if v.Name == baseFieldName { typeInfo += " *" } diff --git a/main.go b/main.go index c5ed7d1fe5f4c2aa34458e2c8a60f6c4be4bac91..013e89f57c6cf082da7e6bab1edf745a7f9fa2e4 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( "github.com/richardwilkes/toolbox/cmdline" ) -const desiredCEFVersion = "73.1.12+gee4b49f+chromium-73.0.3683.75" +const desiredCEFVersion = "74.1.19+gb62bacf+chromium-74.0.3729.157" func main() { cmdline.CopyrightYears = "2018-2019"