Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rune dump Replace #26

Open
kongbaiai2 opened this issue Jun 15, 2022 · 1 comment
Open

rune dump Replace #26

kongbaiai2 opened this issue Jun 15, 2022 · 1 comment

Comments

@kongbaiai2
Copy link

source :
table get value is [awk '{print $2}']。
dump after:
'awk '{print $2}''

dump.go func createTableValues(db *sql.DB, name string) (string, error) {


for key, value := range data {
if value != nil && value.Valid {
dataStrings[key] = value.String
}
}


}
modify-->
for key, value := range data {
if value != nil && value.Valid {
rune := \'
dataStrings[key] = strings.Replace(value.String, "'", rune, -1)
}
}

@kongbaiai2
Copy link
Author

	for key, value := range data {
		if value != nil && value.Valid {

			nonGdk := strings.Trim(fmt.Sprintf("%q", value.String), "\"")
			rune := `'`
			rune1 := `\'`
			nonGdk = strings.Replace(nonGdk, rune, rune1, -1)
			rune2 := `\x00`
			rune3 := `\0`
			nonGdk = strings.Replace(nonGdk, rune2, rune3, -1)

			dataStrings[key] = nonGdk

		}
	}

// utf-8 to string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant