query := `
UPDATE type
SET characteristics = jsonb_insert(
characteristics, array[$1::text], $2::jsonb
)
WHERE id=$3`
tag, err := conn.Exec(ctx, query,
c.Name, // string
struct{ // лучше вынести как отдельный тип
Type string `json:"type"`
Measure string `json:"measure"`
}{c.Type, c.Measure}
c.ID, // uint64
)
type Record struct{
ID string
Name string
Measure Measure
}
type Measure struct{
Type string `json:"type"`
Measure string `json:"measure"`
}
const updateSql = `UPDATE type
SET characteristics = jsonb_insert(characteristics, array[$1], $2::jsonb)
WHERE id=$3`
func update(r Record) error {
//...
tag, err := conn.Exec(ctx, query,
r.Name,
r.Measure,
r.ID,
)
//...
}
file1, err := os.Open(config.First_file)
if err != nil {
log.Fatalln("error")
}
defer file1.Close()
file1Scanner := bufio.NewScanner(file1)
file2, err := os.Open(config.Second_file)
if err != nil {
log.Fatalln("error")
}
defer file2.Close()
file2Scanner := bufio.NewScanner(file2)
scanFiles(file1Scanner, file2Scanner)
if err := file1Scanner.Err(); err != nil {
log.Fatalln(err)
}
if err := file2Scanner.Err(); err != nil {
log.Fatalln(err)
}
return
for _, j := range arr2 {
if strings.Split(i, ":")[1] == strings.Split(j, ":")[0] {
out = append(out, i)
break
}
}
line_first_file := 1
for first_scanner.Scan() {
line_second_file := 1
second_file, err := os.Open(config.Second_file)
if err != nil {
log.Fatalln("error")
return
}
scanner_second := bufio.NewScanner(second_file)
for scanner_second.Scan() {
if strings.Contains(strings.Split(first_scanner.Text(), ":")[1], strings.Split(scanner_second.Text(), ":")[0]) {
log.Println(first_scanner.Text(), scanner_second.Text())
}
second_file.Close()
line_second_file++
}
line_first_file++
}