How to make gopls recognize external github imports - vim

I recently started to work on a Go project.
When I use gopls with Coc, all external imports are not recognized such as "github.com/prometheus/client_golang/prometheus". It complains it could not find this module from neither $GOROOT and $GOPATH.
This project is managed by bazel, and all depedencies are listed in WORKSPACE file. Do I have any way to install all packages based on WORKSPACE file or I have to go install all packages one by one? If the latter, I would imagine keep package version synced is challenaging.

To install all dependencies listed in the WORKSPACE file in a Bazel-managed Go project, you can use the bazel run command and the go_repository rule in the WORKSPACE file.
For example, if you have the following go_repository rule in your WORKSPACE file:
go_repository(
name = "com_github_prometheus_client_golang",
importpath = "github.com/prometheus/client_golang",
version = "0.10.0",
)
You can run the following command to install the dependencies:
bazel run //:gazelle
This will run the gazelle target, which updates the dependencies in the WORKSPACE file and generates the required BUILD files for each package in your project.
Once the dependencies are installed, they should be recognized by gopls in your editor.

Related

Create directory for configuration when running cargo install

I built a tool that requires configuration by means of a config.yaml. I'd like to provide a basic version of that file along with the installation. Is it possible to have customizable task carried out (such as creating a directory under /etc/mytool/ and creating a file herein) when running cargo install --path .?
Build Scripts are your friend.
The Rust file designated by the build command (relative to the package root) will be compiled and invoked before anything else is compiled in the package, allowing your Rust code to depend on the built or generated artifacts. By default Cargo looks up for "build.rs" file in a package root (even if you do not specify a value for build).
Use build = "custom_build_name.rs" to specify a custom build name, e.g. add in Cargo.toml:
[package]
# ...
build = "custom_build_name.rs"

How do you debug a Node.js addon built with CMake.js?

I want to be able to step though my C++ code for a Node.js addon that I am making. I understand that CMake.js has the --debug option, but there is no documentation about it.
I am using the node-addon-api module, in CLion.
After months of blind debugging though the use of Errors to print variables, I have finally figured out how to attach the CLion debugger to a Node.js addon.
Create a new CMake Application configuration.
Fill in these fields:
Target: Your project
Executable: The Node binary (On Unix do which node or where.exe node on Windows)
Program arguments: Path to your JS file
Working directory: The directory where the JS file is located
Before launch: Build
Start this configuration in debug mode.
I recently stumbled on the same problem and had success creating a custom toolchain in CLion 2020.3 with CMake.js on a Linux system.
Reproducible steps:
Install cmake-js via npm install -g cmake-js. Make sure to install the package globally, so that your toolchain becomes available across multiple projects.
Create a npm project, e.g mkdir my-project && cd my-project && npm init.
Run npm install bindings && npm install node-addon-api (For the C++ wrapper).
Create a CMakeLists.txt in the root directory and paste this. Make sure to replace file(GLOB SOURCE_FILES hello.cpp) with your addon-specific cpp and header files.
Open my-project in CLion.
Go to Settings / Preferences | Build, Execution, Deployment | Custom Build Targets and click + to add a new target.
Go to Build | Tool Settings | Program and set it to the cmake-js binary that you downloaded in the npm directory where you keep your global packages.
Set the arguments to compile -D and set the working directory to the root directory of my-project.
Go to Clean | Tool Settings | Program and set it to the directory where you keep your cmake-js binary. Set the arguments to clean and set the working directory to your project's root directory.
Add a new Run Configuration and specify the Toolchain you just created in the Target field. Point the Executable to your node executable and add the .js file where you import your native addons to. Set the working directory to the current directory as well. Now, you can build the target, and also debug the N-API layer of your native code, too!

How set up rapidjson without git

I need to use rapidjson as a third party library to replace libjson. I'm trying to figure out how to build it so I can use it's build files in my project (dependency list).
I downloaded rapidjson from github, and I'm trying to get a buildable project. I'm looking at the instructions at rapidjson website, and it's showing that I need to do the following, below (Installation).
We don't use git, so what would I need to do instead of the git submodule update --init step?
Why would I need a build dir in the include/rapidjson directory with nothing in it?
When I cd to build and type cmake, it seems to be missing parameters. What is the full cmake command? Thanks!
Installation
RapidJSON is a header-only C++ library. Just copy the include/rapidjson folder to system or project's include path.
RapidJSON uses following software as its dependencies:
•CMake as a general build tool
•(optional)Doxygen to build documentation
•(optional)googletest for unit and performance testing
To generate user documentation and run tests please proceed with the steps below:
1.Execute git submodule update --init to get the files of thirdparty submodules (google test).
2.Create directory called build in rapidjson source directory.
3.Change to build directory and run cmake .. command to configure your build. Windows users can do the same with cmake-gui application.
4.On Windows, build the solution found in the build directory. On Linux, run make from the build directory.
On successfull build you will find compiled test and example binaries in bin directory. The generated documentation will be available in doc/html directory of the build tree. To run tests after finished build please run make test or ctest from your build tree. You can get detailed output using ctest -V command.
It is possible to install library system-wide by running make install command from the build tree with administrative privileges. This will install all files according to system preferences. Once RapidJSON is installed, it is possible to use it from other CMake projects by adding find_package(RapidJSON) line to your CMakeLists.txt.
It is header-only library. So if you just want to integrate it into your project, just copy the /include folder to your project, and it should works.
All other instructions are for building unit tests, performance tests and documentation.

DocuSign Objective C REST API setup

I'm trying to set up an Objective C XCode project to test DocuSign API for request a signature via email recipe. These are the steps I've been through now.
Downloaded ObjC client
Copied code from GitHub (docusign-rest-recipes/core_recipes/CoreRecipes.m)
Created a new xcode project with ObjC client and GitHub code.
I now get JSONModel/JSONModel.h file not found.
Please help me on this.
Try installing through Cocoapods if you're having issues with a manual copy. There are instructions listed in the README at the root level of the repo:
https://github.com/docusign/docusign-objc-client
CocoaPods Install
Create a podfile, run pod install, then use the .xcworkspace project file moving forward. To use the clients in this manner, do the following:
At the command line run the following RubyGems command to install cocoapods (note: this might require sudo):
$ gem install cocoapods
Create a file in your root project directory called Podfile with the following content. Replace the two references to PROJECT below with your unique project name:
$ pod 'DocuSignESign', '~> 2.0.0'
Run the following command in the same directory as your Podfile:
$ pod install
Once you are done installing, close Xcode and open the newly created .xcworkspace project file. Make sure you use this work space going forward!

Activating extension `ms-vscode.wordcount` failed: Cannot find module 'd:/VSCode/vscode-wordcount/out/extension'

I try to build and debug an extension in Code.
I downloaded the sample of word-count from https://github.com/microsoft/vscode-wordcount.
When I clicked F5, ./out folder was not generated and I saw failure: Activating extension ms-vscode.wordcount failed: Cannot find module 'd:/VSCode/vscode-wordcount/out/extension'.
I found the post
https://github.com/Microsoft/vscode-go/issues/35
and I think this was because I failed to build the extension.
And I checked my path that node and npm were both set.
I found there were 2 possible issues.
I could not find .\node_modules folder in my extension folder. The folder structure is like
.vscode\
-- launch.json
-- settings.json
-- tasks.json
image\
test\
typings\
-- vscode-typings.d.ts
extension.ts
package.json
tsconfig.json
My node version is v0.12.2.
Could you give me some hints how to investigate the issue?
You probably downloaded directly from GitHub.
You will need to run npm install in your project's folder in order to create the node_modules directory and add the required dependencies.
If you simply want to install the extension to use it, you will also need to:
Move the folder to the correct place
npm install
OR
Install the built version directly from the Visual Studio Marketplace through the command pallet.

Resources