UNPKG

@phoenix-plugin-registry/bokub.go-formatter

Version:

Format your Go files easily with a custom shortcut. This extension uses gofmt to format your code and goimports to manage your imports.

23 lines (17 loc) 644 B
/*global require, exports, $*/ (function () { "use strict"; var child_process = require('child_process'); function formatFile(filePath, gofmtPath, callback) { var command = gofmtPath + ' "' + filePath + '"'; child_process.exec(command, function (err, stdout, stderr) { callback(null, stderr + stdout); }); } exports.init = function (domainManager) { if (!domainManager.hasDomain("gofmt")) { domainManager.registerDomain("gofmt", {major: 1, minor: 0}); } domainManager.registerCommand('gofmt', 'formatFile', formatFile, true); }; }());