Exploring the vscode debug process to resolve issues with running Go programs

Problem Description VSCode cannot run Go projects in run mode (it can only debug in debug mode), and the following error occurs. The obscured part in the image is a package within the project, not a third-party package. This means that when running a Go project in run mode, it cannot find other Go files, only the entry file. Initial Investigation The first thought about not finding other files is an issue with the GO_PATH. However, the project uses Go modules, allowing the creation of projects outside the GO_PATH, so this suspicion is ruled out. Next, I suspected an issue with the VSCode configuration. Each VSCode project has a .launch.json file that configures the environment when running code. Below is the .launch.json from the project. ...

April 20, 2020 · 4 min · Zhiya

Issue with Viper Failing to Read Configuration from etcd

Problem Description Viper (version 1.1.0 in this context) is a comprehensive configuration solution for Go applications, widely used across various projects. etcd is a distributed key-value store, often used as a configuration center. Viper supports reading configurations not only from files but also from remote configuration centers. The following code is used for configuration. viper.AddRemoteProvider("etcd", "http://127.0.0.1:2379", "conf.toml") viper.SetConfigType("toml") err := viper.ReadRemoteConfig() if err != nil { panic(err) } Running this results in the error panic: Remote Configurations Error: No Files Found. Upon investigation, it was found that etcd had TLS enabled, requiring access to its API via HTTPS. The code was updated as follows. ...

April 16, 2020 · 3 min · Zhiya

Using Pipfile Instead of requirements.txt

Many programming languages provide support for environment isolation, such as Node.js with node_modules, Golang with go mod, and Python with virtualenv and pyvenv. To create a dependency snapshot, the pip freeze > requirements.txt command is often used to generate a requirements.txt file. In some scenarios, this method suffices, but in more complex situations, requirements.txt falls short. requirements.txt appdirs==1.4.3 astroid==2.3.3 attrs==19.3.0 black==19.3b0 certifi==2019.11.28 chardet==3.0.4 click==7.1.1 et-xmlfile==1.0.1 Flask==1.1.1 gevent==1.4.0 greenlet==0.4.15 idna==2.9 isort==4.3.21 itsdangerous==1.1.0 jdcal==1.4.1 Jinja2==2.11.1 lazy-object-proxy==1.4.3 MarkupSafe==1.1.1 mccabe==0.6.1 numpy==1.18.2 openpyxl==3.0.3 pandas==1.0.3 pylint==2.4.4 python-dateutil==2.8.1 pytz==2019.3 requests==2.23.0 six==1.14.0 tinydb==3.15.2 toml==0.10.0 typed-ast==1.4.1 urllib3==1.25.8 Werkzeug==1.0.0 wrapt==1.11.2 The requirements.txt file only records the versions of dependencies. If the official PyPI source is slow, and you need to use a faster domestic mirror, you typically have to use pip install -i or modify the global pip.conf file. ...

March 31, 2020 · 3 min · Zhiya

The Peculiar Behavior of Docker COPY When Copying Directories

Problem Description When creating a Docker image, there is a need to copy all files and directories from a certain path into the image. The following Dockerfile was written: FROM alpine WORKDIR /root/test_docker_proj COPY * ./ The original directory structure is as follows: /projects/test_docker_proj ├── Dockerfile ├── dir1 │ ├── dir11 │ │ └── file11 │ └── file1 └── file2 However, the directory structure copied into the Docker image turns out like this: ...

October 28, 2019 · 2 min · Zhiya

Exploring Pandas Read Excel File Error

Problem Description Using Pandas’ read_excel method to read an Excel file with 160,000 rows results in an AssertionError: "/Users/XXX/excel_test/venv/lib/python3.7/site-packages/xlrd/xlsx.py", line 637, in do_row assert 0 <= self.rowx < X12_MAX_ROWS AssertionError Underlying Principle Excel files come in two default formats. Before Excel 2007, files used the .xls format, a specific binary format supporting up to 65,536 rows (16,384 rows before Excel 97) and 256 columns. Starting with Excel 2007, a new XML-based format .xlsx was adopted, supporting up to 1,048,576 rows and 16,384 columns. Note that when converting a .xlsx file to .xls, data beyond 65,536 rows and 256 columns will be lost. ...

August 22, 2019 · 3 min · Zhiya