最近重新燃起学 go 语言的兴趣,起因是修改一个告警信息发送到 IM 的脚本,刚拿到脚本一脸蒙,再后来又要修改这个脚本又是头大。都怪我之前没有学习 go 的基础语法,临时抱佛脚行不得。所以这次下得决心把 go 作为2021年必修技能。

为了减少家庭矛盾 !_!,把家里台式电脑主系统切换到了 FreeBSD,跟游戏彻底88了,经过一个多月已经没有想玩游戏的念头了,更多的时间是在陪家人及怎么打发业余时间,经常996+大小周工作制也没有多少自己的时间,所以现在才知时间的宝贵,而人已到中年。

下面记录了如何在 FreeBSD 里安装 openjdk,安装 jetbrains 出口的 goland IDE编辑器。

pkg search ^openjdk

openjdk8-            Java Development Kit 8

pkg install openjdk8

New packages to be INSTALLED:
        java-zoneinfo: 2020.a
        javavmwrapper: 2.7.6

Message from openjdk8-

This OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and
procfs(5) mounted on /proc.

If you have not done it yet, please do the following:

        mount -t fdescfs fdesc /dev/fd
        mount -t procfs proc /proc

To make it permanent, you need the following lines in /etc/fstab:

fdesc   /dev/fd         fdescfs         rw      0       0
proc    /proc           procfs          rw      0       0

# java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)

pkg install openjdk8 cmake gdb

New packages to be INSTALLED:
        cmake: 3.18.3
        gdb: 9.2_1
        jsoncpp: 1.9.4
        mpfr: 4.1.0
        rhash: 1.3.9
        source-highlight: 3.1.9_1

Number of packages to be installed: 6

- Edit clion-2016.3/bin/ and change run.processes.with.pty=false
- Start CLion and open Settings | Build, Execution, Deployment | Toolchains
- Specify CMake path: /usr/local/bin/cmake and GDB path: /usr/local/bin/gdb

# pkg search jetbrains
jetbrains-clion-2020.2.4       JetBrains CLion IDE
jetbrains-goland-2020.1.4      JetBrains GoLand IDE
jetbrains-mono-2.001,1         Free and open source typeface for developers
jetbrains-phpstorm-2020.2.2    JetBrains PhpStorm IDE
jetbrains-webstorm-2019.3.2    JetBrains JavaScript IDE

pkg install jetbrains-goland-2020.1.4

New packages to be INSTALLED:
        delve: 1.5.0
        intellij-fsnotifier: 20160221_6
        jetbrains-goland: 2020.1.4

Number of packages to be installed: 3

The process will require 618 MiB more space.
196 MiB to be downloaded.

Message from intellij-fsnotifier-20160221_6:

===>   NOTICE:

The intellij-fsnotifier port currently does not have a maintainer. As a result, it is
more likely to have unresolved issues, not be up-to-date, or even be removed in
the future. To volunteer to maintain this port, please create an issue at:

More information about port maintainership is available at:
Message from delve-1.5.0:

Please execute the following commands to prep this system to run delve:

echo "# required for delve" >>/etc/sysctl.conf.local
echo "security.bsd.unprivileged_proc_debug=1" >>/etc/sysctl.conf.local

Then, either reboot or run the following commands to implement the above

service sysctl reload
Message from jetbrains-goland-2020.1.4:

There is a native (faster) file watching support backed by kqueue which is
enabled by default.  If you encounter problems with watching large
trees, you can disable it by adding the following property via the menu
entry Help -> Edit Custom Properties...


# install golang
pkg install go

New packages to be INSTALLED:
        go: 1.15.5,1

Number of packages to be installed: 1

The process will require 283 MiB more space.
76 MiB to be downloaded.

go version
go version go1.15.5 freebsd/amd64

go env


解决 FreeBSD12.1 XFCE4 锁屏无效问题

最近在使用FreeBSD12.1,并安装了 XFCE4,一切都调试的不错,但发现点击屏幕右上角的锁屏按钮没有反应,这个时候点切换用户,就进入了锁屏状态,但无论你输入正确的密码都无法解锁进入桌面,只能重启系统。

解决方法其实很简单,就是少安装了一个xfce4组件 xfce4-screensaver,使用pkg安装过程记录如下:

pkg install xfce4-screensaver
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	pam_helper: 1.1
	xfce4-screensaver: 0.1.10

Number of packages to be installed: 2

The process will require 1 MiB more space.
226 KiB to be downloaded.

Proceed with this action? [y/N]: y
[1/2] Fetching xfce4-screensaver-0.1.10.txz: 100%  222 KiB 227.1kB/s    00:01    
[2/2] Fetching pam_helper-1.1.txz: 100%    4 KiB   3.8kB/s    00:01    
Checking integrity... done (0 conflicting)
[1/2] Installing pam_helper-1.1...
[1/2] Extracting pam_helper-1.1: 100%
[2/2] Installing xfce4-screensaver-0.1.10...
[2/2] Extracting xfce4-screensaver-0.1.10: 100%

安装完成后需要注销重新登录一下XFCE4桌面才会生效。发现还存在的一个问题就上面说过切换用户时会卡住的问题,可使用 CRTL + ALT + F10 快捷键 解决 锁屏时点了切换用户导致解锁不了的问题。


# 强大的图片处理工具,代替photoshop
pkg install gimp
# 系统任务管理器
pkg install xfce4-taskmanager
# 音量调节工具
pkg install xfce4-pulseaudio-plugin
# 截图工具
pkg install xfce4-screenshooter-plugin
# Ristretto 是 Xfce 桌面环境下的图片查看器。
pkg install ristretto
# 简单PDF查询工具,需要在命令行运行
pkg install mupdf
mupdf redme.pdf
# xfce4 安装GUI解压缩软件
pkg install thunar-archive-plugin xarchiver zip unzip p7zip arj lzop gcpio unrar


FreeBSD 13 之后变为了 fusefs.ko,/boot/loader.conf 文件中需要修改为 fusefs_load="YES"
kldload fusefs
kldstat |grep fuse

fdisk /dev/da0
gpart show /dev/da0
gpart list da0

# FAT32
mount -v -t msdosfs /dev/da0 /mnt/u/
# 解决中文乱码
ntfs-3g /dev/ad0s1 /mnt/u -o silent,umask=0,locale=zh_CN.utf8

ntfs-3g /dev/ada1s1 /mnt/a -o silent,umask=0,locale=zh_CN.utf8

GPG 相关

# gpg GUI 管理
pkg install kleopatra