本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
588B

  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package core
  5. import (
  6. "bytes"
  7. "encoding/gob"
  8. )
  9. type PK []interface{}
  10. func NewPK(pks ...interface{}) *PK {
  11. p := PK(pks)
  12. return &p
  13. }
  14. func (p *PK) ToString() (string, error) {
  15. buf := new(bytes.Buffer)
  16. enc := gob.NewEncoder(buf)
  17. err := enc.Encode(*p)
  18. return buf.String(), err
  19. }
  20. func (p *PK) FromString(content string) error {
  21. dec := gob.NewDecoder(bytes.NewBufferString(content))
  22. err := dec.Decode(p)
  23. return err
  24. }
上海开阖软件有限公司 沪ICP备12045867号-1