从sqlite3数据库和模型struct标记读取表时出现问题

I'm trying to implement a function in Go where I need to connect to a sqlite database. This DB has more than one model, and a superior suggested me using the GORM lib. It seems the program detects by name the table I'm attempting to access, but it always returns zero values (numerical attributes) or empty strings.

My first attempt was modelling the schema wihout struct tags, however it was the first time I got the problem. Then I tried using struct tags using the 'db' preffix, specifying the name of every attribute in SQLITE, but nothing changed. After that, I applied struct tags with the 'sql' preffix... Again nothing happened, and got the same problem. As a last attempt I changed the preffix to 'gorm', but got the problem once more. Afterwards, I deleted all the struct tags and left just the struct tag corresponding to the primary key (ID).

I don know what to do but to give GORM up and use another library... :(

The schema in SQLite

TABLE COMPANIES(
   ID INT PRIMARY KEY     NOT NULL,
   NAME           TEXT    NOT NULL,
   AGE            INT     NOT NULL,
   ADDRESS        CHAR(50),
   SALARY         REAL
);

The model I coded

type Company struct {
    gorm.Model
    ID      int `gorm:"PRIMARY_KEY"`
    Name    string
    Age     int
    Address string
    Salary  float32
}
fmt.Println(db.HasTable("COMPANIES"))//It returns "true"
db.First(&company) 
fmt.Println(company)

What is printed in console:

{{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC <nil>} 0  0  0}

[2019-09-11 11:49:09]  no such column: companies.deleted_at 

The weird thing is, the table is actually populated, and has neither zero values nor empty strings.

At the end, I could solve my problem without specifying tags AND deleting the "gorm.Model" line. I had to implement the function "TableName" to indicate which table I want to read. Here's the code:

package main

import (
    "fmt"

    "github.com/jinzhu/gorm"
    _ "github.com/mattn/go-sqlite3"
)

type Company struct {
    ID      int     //`sql:"type: int;primary key; not null"`
    Name    string  //`sql:"type:text; not null "`
    Age     int     //`sql:"type: int; not null"`
    Address string  //`sql:"type: char(50)"`
    Salary  float32 //`sql:"type: real"`
}

func (Company) TableName() string {
    return "COMPANY"
}

(I'm new as a StackOverflow user, so I don know why my answer was suddenly published just by pressing the tab button :-/ )

At the end, I could solve my problem without specifying tags AND deleting the "gorm.Model" line. I had to implement the function "TableName" to indicate which table I want to read. Here's the code:

package main

import (
    "fmt"

    "github.com/jinzhu/gorm"
    _ "github.com/mattn/go-sqlite3"
)

type Company struct {
    ID      int     //`sql:"type: int;primary key; not null"`
    Name    string  //`sql:"type:text; not null "`
    Age     int     //`sql:"type: int; not null"`
    Address string  //`sql:"type: char(50)"`
    Salary  float32 //`sql:"type: real"`
}

func (Company) TableName() string {
    return "COMPANY"//Weirdly, it doesn't have any problem with the case here (it also works if the table name is in lower case.)
}

func main() {

    db, err := gorm.Open("sqlite3", "test.db")
    if err != nil {
        panic("Failed to connect")}

    co := Company{}
    db.First(&co)
    fmt.Println(co)
    cos := []Company{}
    db.Find(&cos)
    fmt.Println(cos)

}

The naming scheme does affect the functionality (as @mh-cbon said), so I had to put all the table names in lower case at the moment when create them.