如何将一个值扫描为零而不进行处理?

In Go I'm trying to write a tool to deal with the structure of MySQL tables, so I have to use a lot of queries like this one

show keys from`table`where`Key_name`='Primary'

In MySQL, I can't wrap this command with a select command and select the columns I want, so when I only want one column (in this case Column_name), how I do deal with the columns that I don't want? Because this query returns all of these other columns as well; Table, Non_unique, Key_name, Seq_in_index, Column_name, Collation, Cardinality, Sub_part, Packed, Null, Index_type, Comment, Index_comment.

In my Go code, I have lines that look like this

err = keysData.Scan(columnName)

It would be cool if I could do something like this though

err = keysData.Scan(_, _, _, _, columnName)

But that doesn't really work, getting cannot use _ as value

Do I have to declare throw away values for each one of these unneeded columns?

I would use the INFORMATION_SCHEMA. This is more versatile than SHOW KEYS because you can select individual columns. For example:

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_NAME='mytable' AND INDEX_NAME='PRIMARY'
ORDER BY SEQ_IN_INDEX

See https://dev.mysql.com/doc/refman/8.0/en/statistics-table.html

For your use case, I also recommend to avoid your approach and use INFORMATION_SCHEMA as @bill-karvin suggested.

But to strictly reply to your question, you could use a dummy sql.Scanner that always succeed, but does nothing:

type dummyScanner struct{}

func (dummyScanner) Scan(v interface{}) error {
    return nil
}

var skip dummyScanner

err = keysData.Scan(skip, skip, skip, skip, columnName, skip, skip, skip, skip, skip, skip, skip, skip)