
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
github.com/jex-lin/golang-mysql-orm-example
Supply Chain Security
Vulnerability
Quality
Maintenance
License
sudo apt-get install mercurial meld
sudo apt-get install mysql-server
go get github.com/go-sql-driver/mysql
go get github.com/coopernurse/gorp
CREATE DATABASE go_test
CREATE TABLE tt (name char(10));
go run main.go
struct 對應 Table field :
type Tt struct {
Name string `db:"name"` // 後面與 db 欄位的對應註釋建議加上
}
- Name 會對應到 tt table 的 name 欄位
- struct 裡的 Name 或 NAME 都可以, 不分大小寫
- struct 裡的欄位首位字母一定要大寫, 而 table 的欄位名稱都可以小寫沒有關係
_, err := dbmap.Select(&existent_video, "select * from videos where source_website = :source_website and file_name = :file_name", map[string]interface{}{"source_website": video.Source_website, "file_name": video.File_name})
var existent_video Video
err = dbmap.SelectOne(&existent_video, "select * from videos where source_website = :source_website and file_name = :file_name", map[string]interface{}{"source_website": video.Source_website, "file_name": video.File_name})
// 結果 : existent_video = {1 "text"}
qq, _ := dbmap.Get(Video{}, 1)
// 結果 : qq = &{1 "text"}
先從 SelectOne 或 Get 拿到 struct (注意 Select 與 Get 結果是不一樣的, 差了 &
在前面)
update_video := &existent_video // 這邊加上 `&`
update_video.Image_url = video.Image_url
update_video.Video_url = video.Video_url
update_video.Source_viewer = video.Source_viewer
update_video.Updated_at = time.Now().Format("2006-01-02 15:04:05")
update_video.File_name = video.File_name
_, err := dbmap.Update(update_video)
if err != nil {
return err
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.